/*
jQWidgets v2.7.0 (2013-Feb-08)
Copyright (c) 2011-2013 jQWidgets.
License: http://jqwidgets.com/license/
 */

(function(b) {
	b.jqx.jqxWidget("jqxGrid", "", {});
	b.extend(b.jqx._jqxGrid.prototype, {
		defineInstance : function() {
			this.disabled = false;
			this.width = 600;
			this.height = 400;
			this.pagerheight = 28;
			this.groupsheaderheight = 34;
			this.pagesize = 10;
			this.pagesizeoptions = [ "5", "10", "20" ];
			this.rowsheight = 25;
			this.columnsheight = 25;
			this.filterrowheight = 30;
			this.groupindentwidth = 30;
			this.rowdetails = false;
			this.enablerowdetailsindent = true;
			this.enablemousewheel = true;
			this.initrowdetails = null;
			this.editable = false;
			this.editmode = "selectedcell";
			this.pageable = false;
			this.groupable = false;
			this.sortable = false;
			this.filterable = false;
			this.autoshowfiltericon = true;
			this.showfiltercolumnbackground = true;
			this.showpinnedcolumnbackground = true;
			this.showsortcolumnbackground = true;
			this.altrows = false;
			this.altstart = 1;
			this.altstep = 1;
			this.showrowdetailscolumn = true;
			this.showtoolbar = false;
			this.toolbarheight = 34;
			this.showstatusbar = false;
			this.statusbarheight = 34;
			this.enableellipsis = true;
			this.groups = [];
			this.groupsrenderer = null;
			this.groupcolumnrenderer = null;
			this.groupsexpandedbydefault = false;
			this.pagerrenderer = null;
			this.touchmode = "auto";
			this.columns = [];
			this.selectedrowindex = -1;
			this.selectedrowindexes = new Array();
			this.selectedcells = new Array();
			this.selectedcell = null;
			this.tableZIndex = 799;
			this.headerZIndex = 499;
			this.updatefilterconditions = null;
			this.showaggregates = false;
			this.showfilterrow = false;
			this.autorowheight = false;
			this.autokoupdates = true;
			this.handlekeyboardnavigation = null;
			this.showsortmenuitems = true;
			this.showfiltermenuitems = true;
			this.showgroupmenuitems = true;
			this.enablebrowserselection = false;
			this.clipboard = true;
			this.ready = null;
			this.updatefilterpanel = null;
			this.autogeneratecolumns = false;
			this.source = {
				beforeprocessing : null,
				beforesend : null,
				loaderror : null,
				localdata : null,
				data : null,
				datatype : "array",
				datafields : [],
				url : "",
				root : "",
				record : "",
				id : "",
				totalrecords : 0,
				recordstartindex : 0,
				recordendindex : 0,
				loadallrecords : true,
				sortcolumn : null,
				sortdirection : null,
				sort : null,
				filter : null,
				sortcomparer : null
			};
			this.dataview = null;
			this.updatedelay = 0;
			this.autoheight = false;
			this.showheader = true;
			this.showgroupsheader = true;
			this.closeablegroups = true;
			this.scrollbarsize = 15;
			this.virtualmode = false;
			this.sort = null;
			this.columnsmenu = true;
			this.columnsresize = false;
			this.columnsreorder = false;
			this.columnsmenuwidth = 15;
			this.autoshowcolumnsmenubutton = true;
			this.popupwidth = "auto";
			this.sorttogglestates = 2;
			this.rendergridrows = null;
			this.enableanimations = true;
			this.enabletooltips = false;
			this.selectionmode = "singlerow";
			this.enablehover = true;
			this.loadingerrormessage = "The data is still loading. When the data binding is completed, the Grid raises the 'bindingcomplete' event. Call this function in the 'bindingcomplete' event handler.";
			this.verticalscrollbarstep = 25;
			this.verticalscrollbarlargestep = 400;
			this.horizontalscrollbarstep = 5;
			this.horizontalscrollbarlargestep = 50;
			this.keyboardnavigation = true;
			this.touchModeStyle = "auto";
			this.autoshowloadelement = true;
			this.showdefaultloadelement = true;
			this.showemptyrow = true;
			this.autosavestate = false;
			this.autoloadstate = false;
			this._updating = false;
			this._pagescache = new Array();
			this._pageviews = new Array();
			this._cellscache = new Array();
			this._rowdetailscache = new Array();
			this._rowdetailselementscache = new Array();
			this._requiresupdate = false;
			this._hasOpenedMenu = false;
			this.scrollmode = "physical";
			this.rtl = false;
			this.events = [ "initialized", "rowclick", "rowselect", "rowunselect", "groupexpand", "groupcollapse", "sort", "columnclick", "cellclick", "pagechanged", "pagesizechanged", "bindingcomplete", "groupschanged", "filter", "columnresized", "cellselect", "cellunselect", "cellbeginedit", "cellendedit", "cellvaluechanged", "rowexpand", "rowcollapse", "rowdoubleclick", "celldoubleclick", "columnreordered" ]
		},
		createInstance : function(d) {
			var i = b("<div tabIndex=0 style='overflow: hidden; -webkit-appearance: none; outline: none; width:100%; height: 100%; align:left; border: 0px; padding: 0px; margin: 0px; left: 0px; top: 0px; valign:top; position: relative;'><div id='wrapper" + this.element.id + "' tabIndex=1 style='overflow: hidden; -webkit-appearance: none; border: none; background: transparent; outline: none; width:100%; height: 100%; padding: 0px; margin: 0px; align:left; left: 0px; top: 0px; valign:top; position: relative;'><div id='toolbar' style='visibility: hidden; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='groupsheader' style='visibility: hidden; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='content" + this.element.id
					+ "' tabIndex=2 style='overflow: hidden; -webkit-appearance: none; border: none; background: transparent; outline: none; border: none; padding: 0px; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; align:left; valign:top; left: 0px; top: 0px; position: absolute;'/><div id='verticalScrollBar" + this.element.id + "' style='align:left; valign:top; left: 0px; top: 0px; position: absolute;'/><div id='horizontalScrollBar" + this.element.id + "' style='align:left; valign:top; left: 0px; top: 0px; position: absolute;'/><div id='bottomRight' style='align:left; valign:top; left: 0px; top: 0px; border: none; position: absolute;'/><div id='statusbar' style='align:left; valign:top; left: 0px; top: 0px; position: absolute;'/><div id='pager' style='align:left; valign:top; left: 0px; top: 0px; position: absolute;'/></div></div>");
			this._fieldsmapping();
			this.element.innerText = "";
			this.element.innerHTML = "";
			this.host.attr("align", "left");
			this.host.append(i);
			this.host.addClass(this.toTP("jqx-grid"));
			this.host.addClass(this.toTP("jqx-reset"));
			this.host.addClass(this.toTP("jqx-rc-all"));
			this.host.addClass(this.toTP("jqx-widget"));
			this.host.addClass(this.toTP("jqx-widget-content"));
			this.wrapper = this.host.find("#wrapper" + this.element.id);
			this.content = this.host.find("#content" + this.element.id);
			this.content.addClass(this.toTP("jqx-reset"));
			var h = this.host.find("#verticalScrollBar" + this.element.id);
			var g = this.host.find("#horizontalScrollBar" + this.element.id);
			this.bottomRight = this.host.find("#bottomRight").addClass(this.toTP("jqx-grid-bottomright"));
			if (!h.jqxScrollBar) {
				alert("jqxscrollbar is not loaded.");
				return
			}
			this.editors = new Array();
			this.vScrollBar = h.jqxScrollBar({
				vertical : true,
				rtl : this.rtl,
				touchMode : this.touchmode,
				step : this.verticalscrollbarstep,
				largestep : this.verticalscrollbarlargestep,
				theme : this.theme,
				_triggervaluechanged : false
			});
			this.hScrollBar = g.jqxScrollBar({
				vertical : false,
				rtl : this.rtl,
				touchMode : this.touchmode,
				step : this.horizontalscrollbarstep,
				largestep : this.horizontalscrollbarlargestep,
				theme : this.theme,
				_triggervaluechanged : false
			});
			this.pager = this.host.find("#pager");
			this.toolbar = this.host.find("#toolbar");
			this.toolbar[0].id = "toolbar" + this.element.id;
			this.toolbar.addClass(this.toTP("jqx-grid-toolbar"));
			this.toolbar.addClass(this.toTP("jqx-widget-header"));
			this.statusbar = this.host.find("#statusbar");
			this.statusbar[0].id = "statusbar" + this.element.id;
			this.statusbar.addClass(this.toTP("jqx-grid-statusbar"));
			this.statusbar.addClass(this.toTP("jqx-widget-header"));
			this.pager.addClass(this.toTP("jqx-grid-pager"));
			this.pager.addClass(this.toTP("jqx-widget-header"));
			this.groupsheader = this.host.find("#groupsheader");
			this.groupsheader.addClass(this.toTP("jqx-grid-groups-header"));
			this.groupsheader.addClass(this.toTP("jqx-widget-header"));
			this.vScrollBar.css("visibility", "hidden");
			this.hScrollBar.css("visibility", "hidden");
			this.vScrollInstance = b.data(this.vScrollBar[0], "jqxScrollBar").instance;
			this.hScrollInstance = b.data(this.hScrollBar[0], "jqxScrollBar").instance;
			this.gridtable = null;
			this.isNestedGrid = this.host.parent() ? this.host.parent().css("z-index") == 2000 : false;
			if (this.localizestrings) {
				this.localizestrings()
			}
			this._builddataloadelement();
			if (this.rowdetailstemplate) {
				if (undefined == this.rowdetailstemplate.rowdetails) {
					this.rowdetailstemplate.rowdetails = "<div></div>"
				}
				if (undefined == this.rowdetailstemplate.rowdetailsheight) {
					this.rowdetailstemplate.rowdetailsheight = 200
				}
				if (undefined == this.rowdetailstemplate.rowdetailshidden) {
					this.rowdetailstemplate.rowdetailshidden = true
				}
			}
			if (this.autorowheight && !this.autoheight) {
				alert('"autorowheight" requires setting the "autoheight" property to true.')
			}
			if (this._testmodules()) {
				return
			}
			this._cachedcolumns = this.columns;
			if (this.rowsheight != 25) {
				this._measureElement("cell")
			}
			if (this.columnsheight != 25) {
				this._measureElement("column")
			}
			this.databind(this.source);
			if (this.showtoolbar) {
				this.toolbar.css("visibility", "visible")
			}
			if (this.showstatusbar) {
				this.statusbar.css("visibility", "visible")
			}
			if (this.pageable && this._initpager) {
				this._initpager()
			}
			this._arrange();
			this.tableheight = null;
			var f = this;
			var e = function() {
				if (f.content) {
					f.content[0].scrollTop = 0;
					f.content[0].scrollLeft = 0
				}
				if (f.gridcontent) {
					f.gridcontent[0].scrollLeft = 0;
					f.gridcontent[0].scrollTop = 0
				}
			};
			this.content.on("mousedown", function() {
				e()
			});
			this.content.on("scroll", function(j) {
				e();
				return false
			});
			if (!this.showfilterrow) {
				if (!this.showstatusbar && !this.showtoolbar) {
					this.host.addClass("jqx-disableselect")
				}
				this.content.addClass("jqx-disableselect")
			}
			if (this.enablebrowserselection) {
				this.content.removeClass("jqx-disableselect");
				this.host.removeClass("jqx-disableselect")
			}
			this.addHandler(this.host, "loadContent", function(j) {
				if (f.gridmenu && f.gridmenu.width() < 120) {
					f._initmenu();
					f.prerenderrequired = true;
					f._rendercolumnheaders()
				}
				return false
			});
			if ((this.width != null && this.width.toString().indexOf("%") != -1) || (this.height != null && this.height.toString().indexOf("%") != -1)) {
				this._updatesizeonwindowresize = true;
				b(window).on("resize." + this.element.id, function() {
					var k = f.host.width();
					var j = f.host.height();
					if (f.autoheight) {
						f._lastHeight = j
					}
					if (f._lastWidth != k || f._lastHeight != j) {
						f._updatesize(f._lastWidth != k, f._lastHeight != j)
					}
					f._lastWidth = k;
					f._lastHeight = j
				})
			}
			if (this.renderstatusbar) {
				this.renderstatusbar(this.statusbar)
			}
			if (this.rendertoolbar) {
				this.rendertoolbar(this.toolbar)
			}
			if (this.disabled) {
				this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"))
			}
			this.hasTransform = b.jqx.utilities.hasTransform(this.host);
			if (this.scrollmode == "logical") {
				this.vScrollInstance.thumbStep = this.rowsheight;
				this.vScrollInstance.step = this.rowsheight
			}
		},
		_builddataloadelement : function() {
			if (this.dataloadelement) {
				this.dataloadelement.remove()
			}
			this.dataloadelement = b('<div style="position: absolute;"></div>');
			if (this.showdefaultloadelement) {
				var d = b('<table cellspacing="0" cellpadding="0" style="z-index: 99999; margin-left: -66px; left: 50%; top: 50%; margin-top: -24px; position: relative; width: 112px; height: 48px; font-family: verdana; font-size: 12px; color: #767676; border-color: #898989; border-width: 1px; border-style: solid; background: #f6f6f6; border-collapse: collapse;"><tbody><tr><td><div style="width: 32px; height: 32px;" class="jqx-grid-load"/></td><td><span style="margin-left: 5px;" >' + this.gridlocalization.loadtext + "</span></td></tr></tbody></table>");
				d.addClass(this.toTP("jqx-rc-all"));
				this.dataloadelement.addClass(this.toTP("jqx-rc-all"));
				this.dataloadelement.append(d)
			} else {
				this.dataloadelement.addClass(this.toTP("jqx-grid-load"))
			}
			this.dataloadelement.width(this.width);
			this.dataloadelement.height(this.height);
			this.host.prepend(this.dataloadelement)
		},
		_measureElement : function(e) {
			var d = b("<span>measure Text</span>");
			d.addClass(this.toTP("jqx-widget"));
			d.addClass(this.toTP("jqx-grid-" + e));
			b(document.body).append(d);
			if (e == "cell") {
				this._cellheight = d.height()
			} else {
				this._columnheight = d.height()
			}
			d.remove()
		},
		_getBodyOffset : function() {
			var e = 0;
			var d = 0;
			if (b("body").css("border-top-width") != "0px") {
				e = parseInt(b("body").css("border-top-width"));
				if (isNaN(e)) {
					e = 0
				}
			}
			if (b("body").css("border-left-width") != "0px") {
				d = parseInt(b("body").css("border-left-width"));
				if (isNaN(d)) {
					d = 0
				}
			}
			return {
				left : d,
				top : e
			}
		},
		_testmodules : function() {
			var k = "";
			var h = this;
			var d = function() {
				if (k.length != "") {
					k += ","
				}
			};
			if (this.columnsmenu && !this.host.jqxMenu && (this.sortable || this.groupable || this.filterable)) {
				d();
				k += " jqxmenu.js"
			}
			if (!this.host.jqxScrollBar) {
				d();
				k += " jqxscrollbar.js"
			}
			if (!this.host.jqxButton) {
				d();
				k += " jqxbuttons.js"
			}
			if (!b.jqx.dataAdapter) {
				d();
				k += " jqxdata.js"
			}
			if (this.pageable && !this.gotopage) {
				d();
				k += "jqxgrid.pager.js"
			}
			if (this.filterable && !this.applyfilters) {
				d();
				k += " jqxgrid.filter.js"
			}
			if (this.groupable && !this._initgroupsheader) {
				d();
				k += " jqxgrid.grouping.js"
			}
			if (this.columnsresize && !this.autoresizecolumns) {
				d();
				k += " jqxgrid.columnsresize.js"
			}
			if (this.columnsreorder && !this.setcolumnindex) {
				d();
				k += " jqxgrid.columnsreorder.js"
			}
			if (this.sortable && !this.sortby) {
				d();
				k += " jqxgrid.sort.js"
			}
			if (this.editable && !this.begincelledit) {
				d();
				k += " jqxgrid.edit.js"
			}
			if (this.showaggregates && !this.getcolumnaggregateddata) {
				d();
				k += " jqxgrid.aggregates.js"
			}
			if (this.keyboardnavigation && !this.selectrow) {
				d();
				k += " jqxgrid.selection.js"
			}
			if (k != "" || this.editable || this.filterable || this.pageable) {
				var f = [];
				var j = function(i) {
					switch (i) {
					case "checkbox":
						if (!h.host.jqxCheckBox && !f.checkbox) {
							f.checkbox = true;
							d();
							k += " jqxcheckbox.js"
						}
						break;
					case "numberinput":
						if (!h.host.jqxNumberInput && !f.numberinput) {
							f.numberinput = true;
							d();
							k += " jqxnumberinput.js"
						}
						break;
					case "datetimeinput":
						if (!h.host.jqxDateTimeInput && !f.datetimeinput) {
							d();
							f.datetimeinput = true;
							k += " jqxdatetimeinput.js(requires: jqxcalendar.js, jquery.global.js)"
						} else {
							if (!b.global && !f.global) {
								d();
								k += " jquery.global.js"
							} else {
								if (!h.host.jqxCalendar && !f.calendar) {
									d();
									k += " jqxcalendar.js"
								}
							}
						}
						break;
					case "combobox":
						if (!h.host.jqxComboBox && !f.combobox) {
							d();
							f.combobox = true;
							k += " jqxcombobox.js(requires: jqxlistbox.js)"
						} else {
							if (!h.host.jqxListBox && !f.listbox) {
								d();
								f.listbox = true;
								k += " jqxlistbox.js"
							}
						}
						break;
					case "dropdownlist":
						if (!h.host.jqxDropDownList && !f.dropdownlist) {
							d();
							f.dropdownlist = true;
							k += " jqxdropdownlist.js(requires: jqxlistbox.js)"
						} else {
							if (!h.host.jqxListBox && !f.listbox) {
								d();
								f.listbox = true;
								k += " jqxlistbox.js"
							}
						}
						break
					}
				};
				if (this.filterable || this.pageable) {
					j("dropdownlist")
				}
				for ( var e = 0; e < this.columns.length; e++) {
					if (this.columns[e] == undefined) {
						continue
					}
					var g = this.columns[e].columntype;
					j(g);
					if (this.filterable && this.showfilterrow) {
						var g = this.columns[e].filtertype;
						if (g == "checkedlist" || g == "bool") {
							j("checkbox")
						}
						if (g == "date") {
							j("datetimeinput")
						}
					}
				}
				if (k != "") {
					alert("Please, add references to the following module(s): " + k);
					this.host.remove();
					return true
				}
			}
			return false
		},
		focus : function() {
			try {
				this.wrapper.focus();
				var e = this;
				setTimeout(function() {
					e.wrapper.focus()
				}, 10);
				this.focused = true
			} catch (d) {
			}
		},
		hiddenParent : function() {
			var e = this;
			if (e.host.css("display") != "block") {
				return true
			}
			var d = false;
			b.each(e.host.parents(), function() {
				if (b(this).css("display") == "none") {
					d = true;
					return false
				}
			});
			return d
		},
		_updatesize : function(i, h) {
			if (this._loading) {
				return
			}
			var f = this;
			if (this.hiddenParent()) {
				return
			}
			var g = f.host.width();
			var e = f.host.height();
			if (!f._oldWidth) {
				f._oldWidth = g
			}
			if (!f._oldHeight) {
				f._oldHeight = e
			}
			if (f._resizeTimer) {
				clearTimeout(f._resizeTimer)
			}
			var d = b.jqx.browser.msie ? 10 : 10;
			f._resizeTimer = setTimeout(function() {
				if (g != f._oldWidth || i == true) {
					f._arrange();
					f._updatecolumnwidths();
					f._updatecellwidths();
					if (!(i == false && f._oldWidth > g)) {
						f._renderrows(f.virtualsizeinfo)
					}
				}
				if (e != f._oldHeight || h == true) {
					var k = f.groupable && f.groups.length > 0;
					var j = f.vScrollBar.css("visibility") != "visible";
					if (!f.autoheight) {
						if (!k) {
							f._arrange();
							f.virtualsizeinfo = f._calculatevirtualheight();
							if (parseInt(e) >= parseInt(f._oldHeight)) {
								f.prerenderrequired = true
							}
							f._renderrows(f.virtualsizeinfo)
						} else {
							if (e >= f._oldHeight) {
								f._render(true, false, false)
							} else {
								f.rendergridcontent(true, false)
							}
						}
						if (j && f.vScrollBar.css("visibility") == "visible") {
							f._arrange();
							f._updatecolumnwidths();
							f._updatecellwidths()
						}
					}
				}
				f._oldWidth = g;
				f._oldHeight = e
			}, d)
		},
		_fieldsmapping : function() {
			if (this.showToolbar) {
				this._mapField("showtoolbar", this.showToolbar)
			}
			if (this.toolbarHeight) {
				this._mapField("toolbarheight", this.toolbarHeight)
			}
			if (this.pagerHeight) {
				this._mapField("pagerHeight", this.pagerHeight)
			}
			if (this.groupsHeaderHeight) {
				this._mapField("groupsHeaderHeight", this.groupsHeaderHeight)
			}
			if (this.pageSize) {
				this._mapField("pageSize", this.pageSize)
			}
			if (this.pagerHeight) {
				this._mapField("pagerHeight", this.pagerHeight)
			}
			if (this.pageSizeOptions) {
				this._mapField("pageSizeOptions", this.pageSizeOptions)
			}
			if (this.rowsHeight) {
				this._mapField("rowsHeight", this.rowsHeight)
			}
			if (this.columnsHeight) {
				this._mapField("columnsHeight", this.columnsHeight)
			}
			if (this.groupIndentWidth) {
				this._mapField("groupIndentWidth", this.groupIndentWidth)
			}
			if (this.rowDetails) {
				this._mapField("rowDetails", this.rowDetails)
			}
			if (this.enableRowDetailsIndent) {
				this._mapField("enableRowDetailsIndent", this.enableRowDetailsIndent)
			}
			if (this.enableMouseWheel) {
				this._mapField("enableMouseWheel", this.enableMouseWheel)
			}
			if (this.initRowDetails) {
				this._mapField("initRowDetails", this.initRowDetails)
			}
			if (this.editMode) {
				this._mapField("editMode", this.editMode)
			}
			if (this.autoShowFilterIcon) {
				this._mapField("autoShowFilterIcon", this.autoShowFilterIcon)
			}
			if (this.showFilterColumnBackground) {
				this._mapField("showFilterColumnBackground", this.showFilterColumnBackground)
			}
			if (this.showPinnedColumnBackground) {
				this._mapField("showPinnedColumnBackground", this.showPinnedColumnBackground)
			}
			if (this.showSortColumnBackground) {
				this._mapField("showSortColumnBackground", this.showSortColumnBackground)
			}
			if (this.altRows) {
				this._mapField("altRows", this.altRows)
			}
			if (this.altStart) {
				this._mapField("altStart", this.altStart)
			}
			if (this.altStep) {
				this._mapField("altStep", this.altStep)
			}
			if (this.showRowDetailsColumn) {
				this._mapField("showRowDetailsColumn", this.showRowDetailsColumn)
			}
			if (this.groupsRenderer) {
				this._mapField("groupsRenderer", this.groupsRenderer)
			}
			if (this.groupColumnRenderer) {
				this._mapField("groupColumnRenderer", this.groupColumnRenderer)
			}
			if (this.groupsExpandedByDefault) {
				this._mapField("groupsExpandedByDefault", this.groupsExpandedByDefault)
			}
			if (this.pagerRenderer) {
				this._mapField("pagerRenderer", this.pagerRenderer)
			}
			if (this.updateDelay) {
				this._mapField("updateDelay", this.updateDelay)
			}
			if (this.autoHeight) {
				this._mapField("autoHeight", this.autoHeight)
			}
			if (this.showHeader) {
				this._mapField("showHeader", this.showHeader)
			}
			if (this.showGroupsHeader) {
				this._mapField("showGroupsHeader", this.showGroupsHeader)
			}
			if (this.closeableGroups) {
				this._mapField("closeableGroups", this.closeableGroups)
			}
			if (this.scrollbarSize) {
				this._mapField("scrollbarSize", this.scrollbarSize)
			}
			if (this.virtualMode) {
				this._mapField("virtualMode", this.virtualMode)
			}
			if (this.columnsMenu) {
				this._mapField("columnsMenu", this.columnsMenu)
			}
			if (this.columnsResize) {
				this._mapField("columnsResize", this.columnsResize)
			}
			if (this.columnsMenuWidth) {
				this._mapField("columnsMenuWidth", this.columnsMenuWidth)
			}
			if (this.sortToggleStates) {
				this._mapField("sortToggleStates", this.sortToggleStates)
			}
			if (this.renderGridRows) {
				this._mapField("renderGridRows", this.renderGridRows)
			}
			if (this.enableAnimations) {
				this._mapField("enableAnimations", this.enableAnimations)
			}
			if (this.enableTooltips) {
				this._mapField("enableTooltips", this.enableTooltips)
			}
			if (this.selectionMode) {
				this._mapField("selectionMode", this.selectionMode)
			}
			if (this.enableHover) {
				this._mapField("enableHover", this.enableHover)
			}
			if (this.loadingErrorMessage) {
				this._mapField("loadingErrorMessage", this.loadingErrorMessage)
			}
			if (this.verticalScrollBarStep) {
				this._mapField("verticalScrollBarStep", this.verticalScrollBarStep)
			}
			if (this.verticalScrollBarLargeStep) {
				this._mapField("verticalScrollBarLargeStep", this.verticalScrollBarLargeStep)
			}
			if (this.horizontalScrollBarStep) {
				this._mapField("horizontalScrollBarStep", this.horizontalScrollBarStep)
			}
			if (this.horizontalScrollbarLargeStep) {
				this._mapField("horizontalScrollbarLargeStep", this.horizontalScrollbarLargeStep)
			}
			if (this.keyboardNavigation) {
				this._mapField("keyboardNavigation", this.keyboardNavigation)
			}
		},
		_mapField : function(d, e) {
			if (d == null) {
				return false
			}
			this[d.toLowerCase()] = e
		},
		getTouches : function(d) {
			if (d.originalEvent) {
				if (d.originalEvent.touches && d.originalEvent.touches.length) {
					return d.originalEvent.touches
				} else {
					if (d.originalEvent.changedTouches && d.originalEvent.changedTouches.length) {
						return d.originalEvent.changedTouches
					}
				}
			}
			if (!d.touches) {
				d.touches = new Array();
				d.touches[0] = d.originalEvent != undefined ? d.originalEvent : d
			}
			return d.touches
		},
		_updateTouchScrolling : function() {
			var e = this;
			if (e.isTouchDevice()) {
				if (e.autoheight) {
					return
				}
				e.scrollmode = "logical";
				e.vScrollInstance.thumbStep = e.rowsheight;
				var g = b.jqx.mobile.getTouchEventName("touchstart");
				var f = b.jqx.mobile.getTouchEventName("touchend");
				var d = b.jqx.mobile.getTouchEventName("touchmove");
				e.enablehover = false;
				if (e.gridcontent) {
					e.gridcontent.off(g + ".touchScroll");
					e.gridcontent.off(d + ".touchScroll");
					e.gridcontent.off(f + ".touchScroll");
					e.gridcontent.off("touchcancel.touchScroll");
					b.jqx.mobile.touchScroll(e.gridcontent[0], e.vScrollInstance.max, function(j, i) {
						if (e.vScrollBar.css("visibility") == "visible") {
							var h = e.vScrollInstance.value;
							e.vScrollInstance.setPosition(h + i)
						}
						if (e.hScrollBar.css("visibility") == "visible") {
							var h = e.hScrollInstance.value;
							e.hScrollInstance.setPosition(h + j)
						}
						e.vScrollInstance.thumbCapture = true;
						e._lastScroll = new Date()
					}, this.element.id);
					if (e._overlayElement) {
						e._overlayElement.off(g + ".touchScroll");
						e._overlayElement.off(d + ".touchScroll");
						e._overlayElement.off(f + ".touchScroll");
						e._overlayElement.off("touchcancel.touchScroll");
						b.jqx.mobile.touchScroll(e._overlayElement[0], e.vScrollInstance.max, function(j, i) {
							if (e.vScrollBar.css("visibility") == "visible") {
								var h = e.vScrollInstance.value;
								e.vScrollInstance.setPosition(h + i)
							}
							if (e.hScrollBar.css("visibility") == "visible") {
								var h = e.hScrollInstance.value;
								e.hScrollInstance.setPosition(h + j)
							}
							e.vScrollInstance.thumbCapture = true;
							e._lastScroll = new Date()
						}, this.element.id);
						this.host.on(g, function() {
							if (!e.editcell) {
								e._overlayElement.css("visibility", "visible")
							} else {
								e._overlayElement.css("visibility", "hidden")
							}
						});
						this.host.on(f, function() {
							if (!e.editcell) {
								e._overlayElement.css("visibility", "visible")
							} else {
								e._overlayElement.css("visibility", "hidden")
							}
						})
					}
				}
			}
		},
		isTouchDevice : function() {
			if (this.touchDevice != undefined) {
				return this.touchDevice
			}
			var d = b.jqx.mobile.isTouchDevice();
			this.touchDevice = d;
			if (this.touchmode == true) {
				d = true;
				b.jqx.mobile.setMobileSimulator(this.element);
				this.touchDevice = d
			} else {
				if (this.touchmode == false) {
					d = false
				}
			}
			if (d && this.touchModeStyle != false) {
				this.scrollbarsize = 10;
				this.touchDevice = true;
				this.host.addClass(this.toThemeProperty("jqx-touch"));
				this.host.find("jqx-widget-content").addClass(this.toThemeProperty("jqx-touch"));
				this.host.find("jqx-widget-header").addClass(this.toThemeProperty("jqx-touch"))
			}
			return d
		},
		toTP : function(d) {
			return this.toThemeProperty(d)
		},
		localizestrings : function(d) {
			this._cellscache = new Array();
			if (b.jqx.dataFormat) {
				b.jqx.dataFormat.cleardatescache()
			}
			if (this._loading) {
				alert(this.loadingerrormessage);
				return false
			}
			if (d != null) {
				if (d.pagergotopagestring) {
					this.gridlocalization.pagergotopagestring = d.pagergotopagestring
				}
				if (d.pagershowrowsstring) {
					this.gridlocalization.pagershowrowsstring = d.pagershowrowsstring
				}
				if (d.pagerrangestring) {
					this.gridlocalization.pagerrangestring = d.pagerrangestring
				}
				if (d.pagernextbuttonstring) {
					this.gridlocalization.pagernextbuttonstring = d.pagernextbuttonstring
				}
				if (d.pagerpreviousbuttonstring) {
					this.gridlocalization.pagerpreviousbuttonstring = d.pagerpreviousbuttonstring
				}
				if (d.groupsheaderstring) {
					this.gridlocalization.groupsheaderstring = d.groupsheaderstring
				}
				if (d.sortascendingstring) {
					this.gridlocalization.sortascendingstring = d.sortascendingstring
				}
				if (d.sortdescendingstring) {
					this.gridlocalization.sortdescendingstring = d.sortdescendingstring
				}
				if (d.sortremovestring) {
					this.gridlocalization.sortremovestring = d.sortremovestring
				}
				if (d.groupbystring) {
					this.gridlocalization.groupbystring = d.groupbystring
				}
				if (d.groupremovestring) {
					this.gridlocalization.groupremovestring = d.groupremovestring
				}
				if (d.firstDay) {
					this.gridlocalization.firstDay = d.firstDay
				}
				if (d.days) {
					this.gridlocalization.days = d.days
				}
				if (d.months) {
					this.gridlocalization.months = d.months
				}
				if (d.AM) {
					this.gridlocalization.AM = d.AM
				}
				if (d.PM) {
					this.gridlocalization.PM = d.PM
				}
				if (d.patterns) {
					this.gridlocalization.patterns = d.patterns
				}
				if (d.percentsymbol) {
					this.gridlocalization.percentsymbol = d.percentsymbol
				}
				if (d.currencysymbol) {
					this.gridlocalization.currencysymbol = d.currencysymbol
				}
				if (d.currencysymbolposition) {
					this.gridlocalization.currencysymbolposition = d.currencysymbolposition
				}
				if (d.decimalseparator) {
					this.gridlocalization.decimalseparator = d.decimalseparator
				}
				if (d.thousandsseparator) {
					this.gridlocalization.thousandsseparator = d.thousandsseparator
				}
				if (d.filterclearstring) {
					this.gridlocalization.filterclearstring = d.filterclearstring
				}
				if (d.filterstring) {
					this.gridlocalization.filterstring = d.filterstring
				}
				if (d.filtershowrowstring) {
					this.gridlocalization.filtershowrowstring = d.filtershowrowstring
				}
				if (d.filterselectallstring) {
					this.gridlocalization.filterselectallstring = d.filterselectallstring
				}
				if (d.filterchoosestring) {
					this.gridlocalization.filterchoosestring = d.filterchoosestring
				}
				if (d.filterorconditionstring) {
					this.gridlocalization.filterorconditionstring = d.filterorconditionstring
				}
				if (d.filterandconditionstring) {
					this.gridlocalization.filterandconditionstring = d.filterandconditionstring
				}
				if (d.filterstringcomparisonoperators) {
					this.gridlocalization.filterstringcomparisonoperators = d.filterstringcomparisonoperators
				}
				if (d.filternumericcomparisonoperators) {
					this.gridlocalization.filternumericcomparisonoperators = d.filternumericcomparisonoperators
				}
				if (d.filterdatecomparisonoperators) {
					this.gridlocalization.filterdatecomparisonoperators = d.filterdatecomparisonoperators
				}
				if (d.filterbooleancomparisonoperators) {
					this.gridlocalization.filterbooleancomparisonoperators = d.filterbooleancomparisonoperators
				}
				if (d.emptydatastring) {
					this.gridlocalization.emptydatastring = d.emptydatastring
				}
				if (d.filterselectstring) {
					this.gridlocalization.filterselectstring = d.filterselectstring
				}
				if (d.loadtext) {
					this.gridlocalization.loadtext = d.loadtext
				}
				if (this._initpager) {
					this._initpager()
				}
				if (this._initgroupsheader) {
					this._initgroupsheader()
				}
				if (this._initmenu) {
					this._initmenu()
				}
				this._builddataloadelement();
				b(this.dataloadelement).css("visibility", "hidden");
				b(this.dataloadelement).css("display", "none");
				if (d.validationstring) {
					this.gridlocalization.validationstring = d.validationstring
				}
				if (this.filterable && this.showfilterrow) {
					if (this._updatefilterrow) {
						for ( var e in this._filterrowcache) {
							b(this._filterrowcache[e]).remove()
						}
						this._filterrowcache = [];
						this._updatefilterrow()
					}
				}
				if (this.showaggregates && this.refresheaggregates) {
					this.refresheaggregates()
				}
				this._renderrows(this.virtualsizeinfo)
			} else {
				this.gridlocalization = {
					"/" : "/",
					":" : ":",
					firstDay : 0,
					days : {
						names : [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
						namesAbbr : [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
						namesShort : [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]
					},
					months : {
						names : [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" ],
						namesAbbr : [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" ]
					},
					AM : [ "AM", "am", "AM" ],
					PM : [ "PM", "pm", "PM" ],
					eras : [ {
						name : "A.D.",
						start : null,
						offset : 0
					} ],
					twoDigitYearMax : 2029,
					patterns : {
						d : "M/d/yyyy",
						D : "dddd, MMMM dd, yyyy",
						t : "h:mm tt",
						T : "h:mm:ss tt",
						f : "dddd, MMMM dd, yyyy h:mm tt",
						F : "dddd, MMMM dd, yyyy h:mm:ss tt",
						M : "MMMM dd",
						Y : "yyyy MMMM",
						S : "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss",
						ISO : "yyyy-MM-dd hh:mm:ss",
						ISO2 : "yyyy-MM-dd HH:mm:ss",
						d1 : "dd.MM.yyyy",
						d2 : "dd-MM-yyyy",
						d3 : "dd-MMMM-yyyy",
						d4 : "dd-MM-yy",
						d5 : "H:mm",
						d6 : "HH:mm",
						d7 : "HH:mm tt",
						d8 : "dd/MMMM/yyyy",
						d9 : "MMMM-dd",
						d10 : "MM-dd",
						d11 : "MM-dd-yyyy"
					},
					percentsymbol : "%",
					currencysymbol : "$",
					currencysymbolposition : "before",
					decimalseparator : ".",
					thousandsseparator : ",",
					pagergotopagestring : "Go to page:",
					pagershowrowsstring : "Show rows:",
					pagerrangestring : " of ",
					pagerpreviousbuttonstring : "previous",
					pagernextbuttonstring : "next",
					groupsheaderstring : "Drag a column and drop it here to group by that column",
					sortascendingstring : "Sort Ascending",
					sortdescendingstring : "Sort Descending",
					sortremovestring : "Remove Sort",
					groupbystring : "Group By this column",
					groupremovestring : "Remove from groups",
					filterclearstring : "Clear",
					filterstring : "Filter",
					filtershowrowstring : "Show rows where:",
					filterorconditionstring : "Or",
					filterandconditionstring : "And",
					filterselectallstring : "(Select All)",
					filterchoosestring : "Please Choose:",
					filterstringcomparisonoperators : [ "empty", "not empty", "contains", "contains(match case)", "does not contain", "does not contain(match case)", "starts with", "starts with(match case)", "ends with", "ends with(match case)", "equal", "equal(match case)", "null", "not null" ],
					filternumericcomparisonoperators : [ "equal", "not equal", "less than", "less than or equal", "greater than", "greater than or equal", "null", "not null" ],
					filterdatecomparisonoperators : [ "equal", "not equal", "less than", "less than or equal", "greater than", "greater than or equal", "null", "not null" ],
					filterbooleancomparisonoperators : [ "equal", "not equal" ],
					validationstring : "Entered value is not valid",
					emptydatastring : "No data to display",
					filterselectstring : "Select Filter",
					loadtext : "Loading..."
				}
			}
		},
		_initmenu : function() {
			var r = this;
			if (this.host.jqxMenu) {
				if (this.gridmenu) {
					if (this.filterable) {
						if (this._destroyfilterpanel) {
							this._destroyfilterpanel()
						}
					}
					this.gridmenu.jqxMenu("destroy");
					this.gridmenu.remove()
				}
				this.menuitemsarray = new Array();
				this.gridmenu = b('<div id="gridmenu' + this.element.id + '" style="z-index: 9999999999999;"></div>');
				this.host.append(this.gridmenu);
				var v = b("<ul></ul>");
				var i = '<div class="jqx-grid-sortasc-icon"></div>';
				var t = b("<li>" + i + this.gridlocalization.sortascendingstring + "</li>");
				var z = '<div class="jqx-grid-sortdesc-icon"></div>';
				var w = b("<li>" + z + this.gridlocalization.sortdescendingstring + "</li>");
				var n = '<div class="jqx-grid-sortremove-icon"></div>';
				var k = b("<li>" + n + this.gridlocalization.sortremovestring + "</li>");
				var j = '<div class="jqx-grid-groupby-icon"></div>';
				var q = b("<li>" + j + this.gridlocalization.groupbystring + "</li>");
				var f = b("<li>" + j + this.gridlocalization.groupremovestring + "</li>");
				var d = b('<li type="separator"></li>');
				var u = b('<li class="filter" style="height: 170px;" ignoretheme="true"><div class="filter"></div></li>');
				var m = this.gridlocalization.sortascendingstring.length;
				var s = this.gridlocalization.sortascendingstring;
				if (this.gridlocalization.sortdescendingstring.length > m) {
					m = this.gridlocalization.sortdescendingstring.length;
					s = this.gridlocalization.sortdescendingstring
				}
				if (this.gridlocalization.sortremovestring.length > m) {
					m = this.gridlocalization.sortremovestring.length;
					s = this.gridlocalization.sortremovestring
				}
				if (this.groupable && this._initgroupsheader && this.showgroupmenuitems) {
					if (this.gridlocalization.groupbystring.length > m) {
						m = this.gridlocalization.groupbystring.length;
						s = this.gridlocalization.groupbystring
					}
					if (this.gridlocalization.groupremovestring.length > m) {
						m = this.gridlocalization.groupremovestring.length;
						s = this.gridlocalization.groupremovestring
					}
				}
				var x = 200;
				s = b.trim(s).replace(/\&nbsp\;/ig, "").replace(/\&#160\;/ig, "");
				var g = b("<span>" + s + "</span>");
				g.addClass(this.toThemeProperty("jqx-menu-item"));
				this.host.append(g);
				x = g.outerWidth() + 60;
				g.remove();
				var e = 0;
				if (this.sortable && this._togglesort && this.showsortmenuitems) {
					v.append(t);
					this.menuitemsarray[0] = t[0];
					v.append(w);
					this.menuitemsarray[1] = w[0];
					v.append(k);
					this.menuitemsarray[2] = k[0];
					e = 3
				}
				if (this.groupable && this._initgroupsheader && this.showgroupmenuitems) {
					v.append(q);
					this.menuitemsarray[3] = q[0];
					v.append(f);
					this.menuitemsarray[4] = f[0];
					e += 2
				}
				var l = e * 27 + 3;
				var p = true;
				if (this.filterable && !this.showfilterrow && this.showfiltermenuitems) {
					if (this._initfilterpanel) {
						this.menuitemsarray[5] = u[0];
						this.menuitemsarray[6] = u[0];
						v.append(d);
						v.append(u);
						l += 176;
						if (b.jqx.browser.msie && b.jqx.browser.version < 8) {
							l += 20
						}
						var o = b(u).find("div:first");
						x += 20;
						this._initfilterpanel(this, o, "", x);
						p = false;
						this.removeHandler(b(document), "click.menu" + r.element.id, r._closemenuafterclick, r);
						this.addHandler(b(document), "click.menu" + r.element.id, r._closemenuafterclick, r)
					} else {
						alert("jqxgrid.filter.js is not loaded.")
					}
				}
				this.gridmenu.append(v);
				if (b.jqx.browser.msie && b.jqx.browser.version < 8 && this.filterable) {
					b("#listBoxfilter1" + this.element.id).css("z-index", 4990);
					b("#listBoxfilter2" + this.element.id).css("z-index", 4990);
					b("#listBoxfilter3" + this.element.id).css("z-index", 4990);
					b("#gridmenu" + this.element.id).css("z-index", 5000);
					b("#gridmenu" + this.element.id).on("initialized", function() {
						b("#menuWrappergridmenu" + r.element.id).css("z-index", 4980)
					})
				}
				if (this.menuitemsarray[0] == undefined) {
					l = 65
				}
				this.removeHandler(this.gridmenu, "keydown");
				this.addHandler(this.gridmenu, "keydown", function(E) {
					if (E.keyCode == 27) {
						r.gridmenu.jqxMenu("close")
					} else {
						if (E.keyCode == 13 && r.filterable) {
							if (r._buildfilter) {
								var D = b(b.find("#filter1" + r.element.id)).jqxDropDownList("container").css("display") == "block";
								var C = b(b.find("#filter2" + r.element.id)).jqxDropDownList("container").css("display") == "block";
								var A = b(b.find("#filter3" + r.element.id)).jqxDropDownList("container").css("display") == "block";
								var F = b(b.find("#filterclearbutton" + r.element.id)).hasClass("jqx-fill-state-focus");
								if (F) {
									var B = b.data(document.body, "contextmenu" + r.element.id).column;
									r._clearfilter(r, r.element, B);
									r.gridmenu.jqxMenu("close")
								} else {
									if (!D && !C && !A) {
										var B = b.data(document.body, "contextmenu" + r.element.id).column;
										r.gridmenu.jqxMenu("close");
										r._buildfilter(r, u, B)
									}
								}
							}
						}
					}
				});
				if (this.popupwidth != "auto") {
					x = this.popupwidth
				}
				this.gridmenu.jqxMenu({
					width : x,
					height : l,
					autoCloseOnClick : p,
					autoOpenPopup : false,
					mode : "popup",
					theme : this.theme,
					animationShowDuration : 0,
					animationHideDuration : 0,
					animationShowDelay : 0
				});
				if (this.filterable) {
					this.gridmenu.jqxMenu("_setItemProperty", u[0].id, "closeOnClick", false)
				}
				if (this.rtl) {
					var y = this;
					b.each(v.find("li"), function() {
						b(this).addClass(y.toTP("jqx-rtl"))
					});
					var h = function(A) {
						var B = A.find("div");
						B.css("float", "right");
						B.css("margin-left", "4px");
						B.css("margin-right", "-4px")
					};
					h(k);
					h(w);
					h(t);
					h(q);
					h(f)
				}
				this._handlemenueevents()
			} else {
				this.columnsmenu = false
			}
		},
		_arrangemenu : function() {
			var i = this.gridlocalization.sortascendingstring.length;
			var d = this.gridlocalization.sortascendingstring;
			if (this.gridlocalization.sortdescendingstring.length > i) {
				i = this.gridlocalization.sortdescendingstring.length;
				d = this.gridlocalization.sortdescendingstring
			}
			if (this.gridlocalization.sortremovestring.length > i) {
				i = this.gridlocalization.sortremovestring.length;
				d = this.gridlocalization.sortremovestring
			}
			if (this.groupable && this._initgroupsheader) {
				if (this.gridlocalization.groupbystring.length > i) {
					i = this.gridlocalization.groupbystring.length;
					d = this.gridlocalization.groupbystring
				}
				if (this.gridlocalization.groupremovestring.length > i) {
					i = this.gridlocalization.groupremovestring.length;
					d = this.gridlocalization.groupremovestring
				}
			}
			var e = 200;
			d = b.trim(d).replace(/\&nbsp\;/ig, "").replace(/\&#160\;/ig, "");
			var f = b("<span>" + d + "</span>");
			f.addClass(this.toThemeProperty("jqx-menu-item"));
			this.host.append(f);
			e = f.outerWidth() + 60;
			f.remove();
			var g = 0;
			if (this.sortable && this._togglesort && this.showsortmenuitems) {
				g = 3
			}
			if (this.groupable && this._initgroupsheader && this.showgroupmenuitems) {
				g += 2
			}
			var h = g * 27 + 3;
			if (this.filterable && this.showfiltermenuitems) {
				if (this._initfilterpanel) {
					h += 176;
					e += 20;
					if (b.jqx.browser.msie && b.jqx.browser.version < 8) {
						h += 20
					}
				}
			}
			if (this.menuitemsarray[0] == undefined) {
				h = 65
			}
			if (this.popupwidth != "auto") {
				e = this.popupwidth
			}
			this.gridmenu.jqxMenu({
				width : e,
				height : h
			})
		},
		_closemenuafterclick : function(e) {
			var h = e != null ? e.data : this;
			var f = false;
			if (e.target.className.indexOf("filter") != -1) {
				return
			}
			if (e.target.className.indexOf("jqx-grid-cell") != -1) {
				h.gridmenu.jqxMenu("close");
				return
			}
			var d = h.host.offset();
			var j = e.pageX;
			var i = e.pageY;
			b.each(b(e.target).parents(), function() {
				if (this.id != null && this.id.indexOf("filter") != -1) {
					f = true;
					return false
				}
				if (this.className.indexOf("filter") != -1) {
					f = true;
					return false
				}
				if (this.className.indexOf("jqx-grid-cell") != -1) {
					h.gridmenu.jqxMenu("close");
					return false
				}
				if (this.className.indexOf("jqx-grid-column") != -1) {
					h.gridmenu.jqxMenu("close");
					return false
				}
			});
			if (f) {
				return
			}
			try {
				var l = b(b.find("#filter1" + h.element.id)).jqxDropDownList("listBox").vScrollInstance._mouseup;
				if (new Date() - l < 100) {
					return
				}
				var k = b(b.find("#filter3" + h.element.id)).jqxDropDownList("listBox").vScrollInstance._mouseup;
				if (new Date() - k < 100) {
					return
				}
			} catch (g) {
			}
			h.gridmenu.jqxMenu("close")
		},
		_handlemenueevents : function() {
			var d = this;
			this.removeHandler(this.gridmenu, "closed");
			this.addHandler(this.gridmenu, "closed", function(e) {
				d._closemenu()
			});
			this.removeHandler(this.gridmenu, "itemclick");
			this.addHandler(this.gridmenu, "itemclick", function(h) {
				var g = h.args;
				for ( var e = 0; e < d.menuitemsarray.length; e++) {
					var j = d.menuitemsarray[e];
					if (g == j) {
						if (b(g).attr("ignoretheme") != undefined) {
							return
						}
						var k = b.data(document.body, "contextmenu" + d.element.id);
						var f = k.column;
						if (d.filterable) {
							d.gridmenu.jqxMenu("close")
						}
						var m = f.displayfield;
						if (m == null) {
							m = f.datafield
						}
						if (k != null) {
							switch (e) {
							case 0:
								d.sortby(m, "ascending", null);
								break;
							case 1:
								d.sortby(m, "descending", null);
								break;
							case 2:
								d.sortby(m, null, null);
								break;
							case 3:
								d.addgroup(f.datafield);
								break;
							case 4:
								d.removegroup(f.datafield);
								break;
							case 5:
								var l = b(d.menuitemsarray[6]);
								b(l).css("display", "block");
								break;
							case 7:
								break
							}
						}
						break
					}
				}
			})
		},
		getdatainformation : function() {
			var d = this.dataview.totalrecords;
			if (this.summaryrows) {
				d += this.summaryrows.length
			}
			return {
				rowscount : d,
				sortinformation : this.getsortinformation(),
				paginginformation : this.getpaginginformation()
			}
		},
		getsortinformation : function() {
			return {
				sortcolumn : this.sortcolumn,
				sortdirection : this.sortdirection
			}
		},
		getpaginginformation : function() {
			return {
				pagenum : this.dataview.pagenum,
				pagesize : this.pagesize,
				pagescount : Math.ceil(this.dataview.totalrecords / this.pagesize)
			}
		},
		_updaterowsproperties : function() {
			this._updatehiddenrows();
			this._updaterowheights();
			this._updaterowdetails()
		},
		_updatehiddenrows : function() {
			var e = this;
			this.hiddens = new Array();
			var d = this.hiddenboundrows;
			b.each(d, function(g) {
				if (this.index != undefined) {
					var f = this.index;
					var h = e.getrowvisibleindex(g);
					e.hiddens[h] = this.hidden
				}
			})
		},
		_updaterowheights : function() {
			var e = this;
			this.heights = new Array();
			var d = this.heightboundrows;
			b.each(d, function(g) {
				if (this.index != undefined) {
					var f = this.index;
					var h = e.getrowvisibleindex(g);
					e.heights[h] = this.height
				}
			})
		},
		_updaterowdetails : function() {
			var d = this;
			this.details = new Array();
			var e = this.detailboundrows;
			b.each(e, function(g) {
				if (this.index != undefined) {
					var f = this.index;
					var h = d.getrowvisibleindex(g);
					d.details[h] = this.details
				}
			})
		},
		_getmenuitembyindex : function(d) {
			if (d == undefined) {
				return null
			}
			return this.menuitemsarray[d]
		},
		_closemenu : function() {
			if (this._hasOpenedMenu) {
				if (this.gridmenu != null) {
					this.gridmenu.jqxMenu("close")
				}
				var h = b.data(document.body, "contextmenu" + this.element.id);
				var e = 16;
				if (h != null && this.autoshowcolumnsmenubutton) {
					if (this.enableanimations) {
						b(h.columnsmenu).animate({
							"margin-left" : 0
						}, "fast", function() {
							b(h.columnsmenu).css("display", "none")
						});
						var g = !this.rtl ? -32 : 0;
						h.column.iconscontainer.animate({
							"margin-left" : g
						}, "fast")
					} else {
						b(h.columnsmenu).css("display", "none");
						var g = !this.rtl ? -32 : 0;
						h.column.iconscontainer.css("margin-left", g)
					}
					b.data(document.body, "contextmenu" + this.element.id, null)
				}
				this._hasOpenedMenu = false;
				var j = this._getmenuitembyindex(5);
				if (j) {
					var i = b(j).find("#filter1" + this.element.id);
					var d = b(j).find("#filter2" + this.element.id);
					var f = b(j).find("#filter3" + this.element.id);
					i.jqxDropDownList("hideListBox");
					d.jqxDropDownList("hideListBox");
					f.jqxDropDownList("hideListBox")
				}
			}
		},
		scrolloffset : function(e, d) {
			if (e == null || d == null || e == undefined || d == undefined) {
				return
			}
			this.vScrollBar.jqxScrollBar("setPosition", e);
			this.hScrollBar.jqxScrollBar("setPosition", d)
		},
		scrollleft : function(d) {
			if (d == null || d == undefined) {
				return
			}
			this.hScrollBar.jqxScrollBar("setPosition", d)
		},
		scrolltop : function(d) {
			if (d == null || d == undefined) {
				return
			}
			this.vScrollBar.jqxScrollBar("setPosition", d)
		},
		beginupdate : function() {
			this._updating = true;
			this._datachanged = false
		},
		endupdate : function() {
			this.resumeupdate()
		},
		resumeupdate : function() {
			this._updating = false;
			if (this._datachanged == true) {
				var d = this.vScrollInstance.value;
				this.render(true, true, false);
				this._datachanged = false;
				if (d != 0 && d < this.vScrollInstance.max) {
					this.scrolltop(d)
				}
			} else {
				this.rendergridcontent(true);
				this._renderrows(this.virtualsizeinfo)
			}
		},
		updating : function() {
			return this._updating
		},
		showloadelement : function() {
			if (this.renderloadelement) {
				this.dataloadelement.html(this.renderloadelement())
			}
			b(this.dataloadelement).css("visibility", "visible");
			b(this.dataloadelement).css("display", "block")
		},
		hideloadelement : function() {
			b(this.dataloadelement).css("visibility", "hidden");
			b(this.dataloadelement).css("display", "none")
		},
		_updatefocusedfilter : function() {
			var d = this;
			if (d.focusedfilter) {
				d.focusedfilter.focus();
				setTimeout(function() {
					d.focusedfilter.focus();
					if (d.focusedfilter[0].nodeName.toLowerCase() == "input") {
						var g = d.focusedfilter.val().length;
						try {
							if ("selectionStart" in d.focusedfilter[0]) {
								d.focusedfilter[0].setSelectionRange(g, g)
							} else {
								var e = d.focusedfilter[0].createTextRange();
								e.collapse(true);
								e.moveEnd("character", g);
								e.moveStart("character", g);
								e.select()
							}
						} catch (f) {
						}
					}
				}, 10)
			}
		},
		databind : function(g, i) {
			if (this.host.css("display") == "block") {
				if (this.autoshowloadelement) {
					b(this.dataloadelement).css("visibility", "visible");
					b(this.dataloadelement).css("display", "block");
					this.dataloadelement.width(this.host.width());
					this.dataloadelement.height(this.host.height())
				} else {
					b(this.dataloadelement).css("visibility", "hidden");
					b(this.dataloadelement).css("display", "none")
				}
			}
			if (!this._initgroupsheader && this.groups.length > 0) {
				this.groups = new Array()
			}
			var f = this;
			if (g == null) {
				g = {}
			}
			if (!g.recordstartindex) {
				g.recordstartindex = 0
			}
			if (!g.recordendindex) {
				g.recordendindex = 0
			}
			if (g.loadallrecords == undefined || g.loadallrecords == null) {
				g.loadallrecords = true
			}
			if (g.sortcomparer == undefined || g.sortcomparer == null) {
				g.sortcomparer = null
			}
			if (g.filter == undefined || g.filter == null) {
				g.filter = null
			}
			if (g.sort == undefined || g.sort == null) {
				g.sort = null
			}
			if (g.data == undefined || g.data == null) {
				g.data = null
			}
			var d = null;
			if (g != null) {
				d = g._source != undefined ? g._source.url : g.url
			}
			this.dataview = this.dataview || new b.jqx.dataview();
			if (b.jqx.dataview.sort) {
				b.extend(this.dataview, new b.jqx.dataview.sort())
			}
			if (b.jqx.dataview.grouping) {
				b.extend(this.dataview, new b.jqx.dataview.grouping())
			}
			this.dataview.suspendupdate();
			this.dataview.pageable = this.pageable;
			this.dataview.groupable = this.groupable;
			this.dataview.groups = this.groups;
			this.dataview.virtualmode = this.virtualmode;
			this.dataview.grid = this;
			this.dataview._clearcaches();
			if (!f.initializedcall) {
				if (this.pageable) {
					if (g._source) {
						if (this.sortable) {
							if (g._source.sortcolumn != undefined) {
								this.sortcolumn = g._source.sortcolumn;
								this.source.sortcolumn = this.sortcolumn;
								this.dataview.sortfield = g._source.sortcolumn;
								g._source.sortcolumn = null
							}
							if (g._source.sortdirection != undefined) {
								this.dataview.sortfielddirection = g._source.sortdirection;
								var h = g._source.sortdirection;
								if (h == "a" || h == "asc" || h == "ascending" || h == true) {
									var e = true
								} else {
									var e = false
								}
								if (h != null) {
									this.sortdirection = {
										ascending : e,
										descending : !e
									}
								} else {
									this.sortdirection = {
										ascending : false,
										descending : false
									}
								}
							}
						}
						if (g._source.pagenum != undefined) {
							this.dataview.pagenum = g._source.pagenum
						}
						if (g._source.pagesize != undefined) {
							this.pagesize = g._source.pagesize;
							this.dataview.pagesize = g._source.pagesize
						} else {
							this.dataview.pagesize = g._source.pagesize;
							if (this.dataview.pagesize == undefined) {
								this.dataview.pagesize = this.pagesize
							}
						}
					}
				}
				if (this.sortable) {
					if (g.sortcolumn) {
						this.dataview.sortfield = g.sortcolumn
					}
					if (g.sortdirection) {
						this.dataview.sortfielddirection = g.sortdirection
					}
				}
				if (this.autoloadstate) {
					if (this.loadstate) {
						this.loadstate()
					}
				}
			}
			this._loading = true;
			this.dataview.update = function(l) {
				f._loading = false;
				if (f.dataview.isupdating()) {
					f.dataview.resumeupdate(false)
				}
				if (f.pageable && f.pagerrenderer) {
					if (f._initpager) {
						f._initpager()
					} else {
						alert("jqxgrid.pager.js is not loaded.")
					}
				}
				if ((f.source.sortcolumn) && f.sortby && !f.virtualmode) {
					f.render();
					f.sortby(f.source.sortcolumn, f.source.sortdirection, f.source.sortcomparer);
					f.source.sortcolumn = null
				} else {
					var k = f.vScrollInstance.value;
					var n = f.hScrollInstance.value;
					var o = f.source.datatype;
					if (o != "local" || o != "array") {
						var p = f.virtualsizeinfo == null || (f.virtualsizeinfo != null && f.virtualsizeinfo.virtualheight == 0);
						if (i == "cells") {
							var m = false;
							if (f.filterable && f._initfilterpanel && f.dataview.filters.length) {
								m = true
							}
							if (false == l) {
								if (!f.vScrollInstance.isScrolling() && !f.hScrollInstance.isScrolling()) {
									f._cellscache = new Array();
									f._pagescache = new Array();
									f._renderrows(f.virtualsizeinfo);
									if (f.showfilterrow && f.filterable && f.filterrow) {
										f._updatelistfilters()
									}
									if (f.showaggregates && f._updateaggregates) {
										f._updateaggregates()
									}
								}
								if (f.autoshowloadelement) {
									b(f.dataloadelement).css("visibility", "hidden");
									b(f.dataloadelement).css("display", "none")
								}
								return
							} else {
								if (m) {
									i = "filter"
								} else {
									if (f.sortcolumn != undefined) {
										i = "sort"
									}
								}
							}
						}
						if (!f.virtualmode || p || (f.virtualmode && f.pageable)) {
							if (f.initializedcall == true && i == "pagechanged") {
								f.rendergridcontent(true);
								if (f.pageable && f.updatepagerdetails) {
									f.updatepagerdetails();
									if (f.autoheight) {
										f._updatepageviews();
										if (f.autorowheight) {
											f._renderrows(this.virtualsizeinfo)
										}
									}
								}
								if (f.showaggregates && f._updateaggregates) {
									f._updateaggregates()
								}
							} else {
								if (i == "filter") {
									f._render(true, true, false, false, false);
									f._updatefocusedfilter();
									f._updatecolumnwidths();
									f._updatecellwidths();
									f._renderrows(f.virtualsizeinfo)
								} else {
									if (i == "sort") {
										f.rendergridcontent(true);
										if (f.showaggregates && f._updateaggregates) {
											f._updateaggregates()
										}
									} else {
										if (i == "data") {
											f._render(true, true, false, false, false)
										} else {
											f._render(true, true, true, f.menuitemsarray && !f.virtualmode)
										}
									}
								}
							}
						} else {
							if (f.virtualmode && f.dataview.totalrecords == 0 && f.dataview.filters.length > 0) {
								f._render(true, true, true, f.menuitemsarray && !f.virtualmode)
							} else {
								f._pagescache = new Array();
								f._renderrows(f.virtualsizeinfo)
							}
						}
						if (f.vScrollInstance.value != k && k <= f.vScrollInstance.max) {
							f.vScrollInstance.setPosition(k)
						}
						if (f.hScrollInstance.value != n && n <= f.hScrollInstance.max) {
							f.hScrollInstance.setPosition(n)
						}
					}
				}
				if (f.autoshowloadelement) {
					b(f.dataloadelement).css("visibility", "hidden");
					b(f.dataloadelement).css("display", "none")
				}
				if (f.pageable) {
					if (f.pagerrightbutton) {
						f.pagerrightbutton.jqxButton({
							disabled : false
						});
						f.pagerleftbutton.jqxButton({
							disabled : false
						});
						f.pagershowrowscombo.jqxDropDownList({
							disabled : false
						})
					}
				}
				f._raiseEvent(11);
				if (!f.initializedcall) {
					f._raiseEvent(0);
					f.initializedcall = true;
					if (f.ready) {
						f.ready()
					}
					if (f.autoloadstate) {
						if (f.loadstate) {
							f._loadselectionandcolumnwidths()
						}
					}
					if ((f.width != null && f.width.toString().indexOf("%") != -1) || (f.height != null && f.height.toString().indexOf("%") != -1)) {
						f._updatesize(true)
					}
					if (f.host.css("visibility") == "hidden") {
						var j = b.jqx.browser.msie && b.jqx.browser.version < 8;
						if (f.vScrollBar.css("visibility") == "visible") {
							f.vScrollBar.css("visibility", "inherit")
						}
						if (f.hScrollBar.css("visibility") == "visible") {
							f.hScrollBar.css("visibility", "inherit")
						}
						f._intervalTimer = setInterval(function() {
							if (f.host.css("visibility") == "visible") {
								f._updatesize(true);
								clearInterval(f._intervalTimer)
							}
						}, 100)
					}
				} else {
					f._updateTouchScrolling()
				}
			};
			this.dataview.databind(g);
			if (this.dataview.isupdating()) {
				if (d != undefined) {
					this.dataview.suspend = false
				} else {
					this.dataview.resumeupdate(false)
				}
			}
			this._initializeRows()
		},
		scrollto : function(e, d) {
			if (undefined != e) {
				this.hScrollInstance.setPosition(e)
			}
			if (undefined != d) {
				this.vScrollInstance.setPosition(d)
			}
		},
		scrollposition : function() {
			return {
				top : this.vScrollInstance.value,
				left : this.hScrollInstance.value
			}
		},
		ensurerowvisible : function(h) {
			var e = this._getpagesize();
			var g = Math.floor(h / e);
			if (!this._pageviews[g] && !this.pageable) {
				this._updatepageviews()
			}
			var n = false;
			if (this.pageable && this.gotopage && !this.virtualmode) {
				if (this.dataview.pagenum != g) {
					this.gotopage(g);
					n = true
				}
			}
			var l = this.vScrollInstance.value;
			var m = this._gettableheight() - this.rowsheight;
			var d = e * (h / e - g);
			d = Math.round(d);
			if (this._pageviews[g]) {
				var k = this._pageviews[g].top;
				var j = k + d * this.rowsheight;
				if (this.rowdetails) {
					for ( var f = e * g; f < h; f++) {
						if (this.details[f]) {
							if (this.details[f].rowdetailshidden == false) {
								j += this.details[f].rowdetailsheight
							}
						}
					}
				}
				if (this.scrollmode == "deferred") {
					if (this.vScrollInstance.max <= j + this.rowsheight) {
						j = this.vScrollInstance.max
					}
				}
				if (j < l) {
					this.scrolltop(j);
					n = true
				} else {
					if (j > l + m + 2) {
						this.scrolltop(j - m);
						n = true
					}
				}
			} else {
				if (this.pageable) {
					var j = d * this.rowsheight;
					if (this.rowdetails) {
						for ( var f = e * g; f < e * g + d; f++) {
							if (this.details[f].rowdetailshidden == false) {
								j += this.details[f].rowdetailsheight
							}
						}
					}
					if (j < l || j > l + m) {
						this.scrollto(0, j);
						n = true
					}
				}
			}
			return n
		},
		ensurecellvisible : function(h, d) {
			var n = this;
			var i = this.hScrollBar.jqxScrollBar("value");
			var j = n.hScrollInstance.max;
			if (n.rtl) {
				if (this.hScrollBar.css("visibility") != "visible") {
					j = 0
				}
			}
			var o = this.ensurerowvisible(h);
			var e = 0;
			if (this.columns.records) {
				var m = i;
				var l = this.host.width();
				var k = 0;
				var f = this.vScrollBar.css("visibility") == "visible" ? 20 : 0;
				var g = false;
				b.each(this.columns.records, function() {
					if (this.datafield == d) {
						var q = 0;
						var p = !n.rtl ? m : j - i;
						if (e + this.width > p + l - f) {
							q = e + this.width - l + f;
							if (n.rtl) {
								q = j - q
							}
							n.scrollleft(q);
							g = true
						} else {
							if (e <= p) {
								q = e - this.width;
								if (n.rtl) {
									q = j - q
								}
								n.scrollleft(q);
								g = true
							}
						}
						if (k == 0) {
							if (n.rtl) {
								n.scrollleft(j)
							} else {
								n.scrollleft(0)
							}
							g = true
						} else {
							if (k == n.columns.records.length - 1) {
								if (n.hScrollBar.css("visibility") == "visible") {
									if (!n.rtl) {
										n.scrollleft(n.hScrollBar.jqxScrollBar("max"))
									} else {
										n.scrollleft(n.hScrollBar.jqxScrollBar("min"))
									}
									g = true
								}
							}
						}
						return false
					}
					k++;
					e += this.width
				});
				if (!g) {
					n.scrollleft(m)
				}
			}
			return o
		},
		setrowheight : function(e, d) {
			if (this._loading) {
				alert(this.loadingerrormessage);
				return false
			}
			if (e == null || d == null) {
				return false
			}
			this.heightboundrows[e] = {
				index : e,
				height : d
			};
			e = this.getrowvisibleindex(e);
			if (e < 0) {
				return false
			}
			if (this.rows.records[e]) {
				this.rows.records[e].height = d
			} else {
				row = new a(this, null);
				row.height = d;
				this.rows.replace(e, row)
			}
			this.heights[e] = d;
			this.rendergridcontent(true);
			return true
		},
		getrowheight : function(d) {
			if (d == null) {
				return null
			}
			d = this.getrowvisibleindex(d);
			if (d < 0) {
				return false
			}
			if (this.rows.records[d]) {
				return this.rows.records[d].height
			}
		},
		setrowdetails : function(e, f, d, h) {
			if (e == undefined || e == null || e < 0) {
				return
			}
			var g = this.dataview.generatekey();
			this.detailboundrows[e] = {
				index : e,
				details : {
					rowdetails : f,
					rowdetailsheight : d,
					rowdetailshidden : h,
					key : g
				}
			};
			e = this.getrowvisibleindex(e);
			if (e < 0) {
				return false
			}
			return this._setrowdetails(e, f, d, h, g)
		},
		getcolumn : function(d) {
			var e = null;
			if (this.columns.records) {
				b.each(this.columns.records, function() {
					if (this.datafield == d || this.displayfield == d) {
						e = this;
						return false
					}
				})
			}
			return e
		},
		_getcolumnindex : function(e) {
			var d = -1;
			if (this.columns.records) {
				b.each(this.columns.records, function() {
					d++;
					if (this.datafield == e) {
						return false
					}
				})
			}
			return d
		},
		_getcolumnat : function(d) {
			var e = this.columns.records[d];
			return e
		},
		_getprevvisiblecolumn : function(e) {
			var d = this;
			while (e > 0) {
				e--;
				var f = d.getcolumnat(e);
				if (!f) {
					return null
				}
				if (!f.hidden) {
					return f
				}
			}
			return null
		},
		_getnextvisiblecolumn : function(e) {
			var d = this;
			while (e < this.columns.records.length) {
				e++;
				var f = d.getcolumnat(e);
				if (!f) {
					return null
				}
				if (!f.hidden) {
					return f
				}
			}
			return null
		},
		getcolumnat : function(d) {
			if (!isNaN(d)) {
				var e = this.columns.records[d];
				return e
			}
			return null
		},
		_getcolumn : function(d) {
			var e = null;
			b.each(this._columns, function() {
				if (this.datafield == d || this.displayfield == d) {
					e = this;
					return false
				}
			});
			return e
		},
		_setcolumnproperty : function(e, g, h) {
			if (e == null || g == null || h == null) {
				return null
			}
			var f = this.getcolumn(e);
			if (f == null) {
				return
			}
			var i = f[g];
			f[g] = h;
			var d = this._getcolumn(e);
			if (d != null) {
				d[g] = h
			}
			this._cellscache = new Array();
			switch (g) {
			case "text":
				this.prerenderrequired = true;
				this._rendercolumnheaders();
				if (this._groupsheader()) {
					if (this._initgroupsheader) {
						this._initgroupsheader()
					}
				}
				break;
			case "editable":
			case "resizable":
			case "draggable":
				if (g == "editable") {
					if (h != i) {
						if (this.editcell != null && this.endcelledit) {
							this.endcelledit(this.editcell.row, this.editcell.column, true, true)
						}
						if (f.columntype == "checkbox") {
							this.prerenderrequired = true;
							this.rendergridcontent(true, false);
							if (this.updating()) {
								return false
							}
						}
						if (this.updating()) {
							return false
						}
						this._renderrows(this.virtualsizeinfo)
					}
				}
				break;
			case "hidden":
			case "hideable":
			case "renderer":
			case "cellsrenderer":
			case "align":
			case "cellsalign":
			case "cellsformat":
			case "pinned":
			case "contenttype":
			case "filterable":
			case "groupable":
			case "cellclass":
			case "class":
				this.prerenderrequired = true;
				this.rendergridcontent(true);
				if (this.updating()) {
					return false
				}
				this._renderrows(this.virtualsizeinfo);
				break;
			case "width":
			case "minwidth":
			case "maxwidth":
				if (this.updating()) {
					return false
				}
				this._updatecolumnwidths();
				this._updatecellwidths();
				this._renderrows(this.virtualsizeinfo);
				break
			}
		},
		_getcolumnproperty : function(d, f) {
			if (d == null || f == null) {
				return null
			}
			var e = this.getcolumn(d);
			return e[f]
		},
		setcolumnproperty : function(d, e, f) {
			this._setcolumnproperty(d, e, f)
		},
		getcolumnproperty : function(d, e) {
			return this._getcolumnproperty(d, e)
		},
		hidecolumn : function(d) {
			this._setcolumnproperty(d, "hidden", true)
		},
		showcolumn : function(d) {
			this._setcolumnproperty(d, "hidden", false)
		},
		iscolumnvisible : function(d) {
			return !this._getcolumnproperty(d, "hidden")
		},
		pincolumn : function(d) {
			this._setcolumnproperty(d, "pinned", true)
		},
		unpincolumn : function(d) {
			this._setcolumnproperty(d, "pinned", false)
		},
		iscolumnpinned : function(d) {
			return this._getcolumnproperty(d, "pinned")
		},
		_setrowdetails : function(j, d, n, h, e) {
			if (n == 0) {
				n = 100
			}
			if (j == null || n == null) {
				return false
			}
			if (e != null) {
				this.details[j] = {
					rowdetails : d,
					rowdetailsheight : n,
					rowdetailshidden : h,
					detailskey : e
				}
			} else {
				var m = this.details[j] != null ? this.details[j].detailskey : null;
				var l = {
					rowdetails : d,
					rowdetailsheight : n,
					rowdetailshidden : h,
					detailskey : m
				};
				var k = this;
				for ( var g = 0; g < this.detailboundrows.length; g++) {
					if (this.detailboundrows[g] != undefined) {
						var f = this.detailboundrows[g];
						if (f.details.detailskey == m) {
							f.details.rowdetailsheight = l.rowdetailsheight;
							f.details.rowdetailshidden = l.rowdetailshidden;
							f.details.rowdetails = l.rowdetails;
							break
						}
					}
				}
				this.details[j] = l
			}
			this.rendergridcontent(true);
			return true
		},
		getrowdetails : function(d) {
			if (d == null) {
				return false
			}
			d = this.getrowvisibleindex(d);
			return this._getrowdetails(d)
		},
		_getrowdetails : function(d) {
			if (d == null) {
				return false
			}
			if (d < 0) {
				return false
			}
			if (this.details[d]) {
				return this.details[d]
			}
			if (this.rowdetailstemplate) {
				return this.rowdetailstemplate
			}
		},
		getrecordscount : function() {
			return this.dataview.totalrecords
		},
		showrowdetails : function(d) {
			if (this._loading) {
				alert(this.loadingerrormessage);
				return false
			}
			if (d == null) {
				return false
			}
			d = this.getrowvisibleindex(d);
			if (d < 0) {
				return false
			}
			var e = this._getrowdetails(d);
			return this._setrowdetailsvisibility(d, e, false)
		},
		hiderowdetails : function(d) {
			if (this._loading) {
				alert(this.loadingerrormessage);
				return false
			}
			d = this.getrowvisibleindex(d);
			if (d < 0) {
				return false
			}
			var e = this._getrowdetails(d);
			return this._setrowdetailsvisibility(d, e, true)
		},
		_togglerowdetails : function(g) {
			var d = g.visibleindex;
			var e = this._getrowdetails(d);
			if (e != null) {
				var f = !e.rowdetailshidden;
				return this._setrowdetailsvisibility(d, e, f)
			}
			return false
		},
		_setrowdetailsvisibility : function(e, f, h) {
			if (this.rowdetailstemplate) {
				if (!this.details) {
					this.details = new Array()
				}
				if (!this.details[e]) {
					this.details[e] = {
						rowdetailshidden : this.rowdetailstemplate.rowdetailshidden,
						rowdetailsheight : this.rowdetailstemplate.rowdetailsheight,
						rowdetails : this.rowdetailstemplate.rowdetails
					};
					var g = this.dataview.generatekey();
					this.details[e].detailskey = g;
					this.detailboundrows[e] = {
						index : e,
						details : this.details[e]
					}
				}
			}
			if (f != null) {
				this.details[e].rowdetailshidden = h
			} else {
				return false
			}
			var d = this.details[e];
			if (h) {
				this._raiseEvent(21, {
					rowindex : e,
					details : d.rowdetails,
					height : d.rowdetailsheight
				})
			} else {
				this._raiseEvent(20, {
					rowindex : e,
					details : d.rowdetails,
					height : d.rowdetailsheight
				})
			}
			return this._setrowdetails(e, d.rowdetails, d.rowdetailsheight, d.rowdetailshidden)
		},
		getrowvisibleindex : function(d) {
			if (d == undefined || d == null || d < 0) {
				return false
			}
			if (this.virtualmode) {
				var e = this.dataview.loadedrecords[d];
				if (e == undefined) {
					return -1
				}
				return e.visibleindex
			}
			var e = this.dataview.bounditems[d];
			if (e == undefined) {
				return -1
			}
			return e.visibleindex
		},
		hiderow : function(d) {
			if (this._loading) {
				alert(this.loadingerrormessage);
				return false
			}
			if (d == undefined || d == null || d < 0) {
				return false
			}
			if (d == null) {
				return false
			}
			this.hiddenboundrows[d] = {
				index : d,
				hidden : true
			};
			d = this.getrowvisibleindex(d);
			return this._setrowvisibility(d, true)
		},
		showrow : function(d) {
			if (this._loading) {
				alert(this.loadingerrormessage);
				return false
			}
			if (d == undefined || d == null || d < 0) {
				return false
			}
			if (d == null) {
				return false
			}
			this.hiddenboundrows[d] = {
				index : d,
				hidden : false
			};
			d = this.getrowvisibleindex(d);
			return this._setrowvisibility(d, false)
		},
		isrowhiddenat : function(d) {
			if (d == null) {
				return null
			}
			d = this.getrowvisibleindex(d);
			if (this.rows.records[d]) {
				return this.rows.records[d].hidden
			}
		},
		_setrowvisibility : function(d, f, e) {
			if (d == null) {
				return false
			}
			this.hiddens[d] = f;
			if (e == undefined || e) {
				this.rendergridcontent(true);
				return true
			}
			return false
		},
		_loadrows : function() {
			if (!this._pageviews[this.dataview.pagenum] && !this.pageable) {
				return
			}
			var p = !this.pageable ? this._pageviews[this.dataview.pagenum].top : 0;
			if (!this.pageable && this._pagescache[this.dataview.pagenum] != undefined) {
				return null
			}
			if (!this.virtualsizeinfo) {
				return
			}
			var t = this;
			var l = new Array();
			var q = new Array();
			var e = t.groupable && t.groups.length > 0;
			var j = this.dataview.totalrecords;
			var o = this.virtualsizeinfo.virtualheight;
			var s = 0;
			this.rows.beginupdate();
			var f = this.dataview.pagesize;
			if (this.pageable && e) {
				f = this.dataview.rows.length
			}
			for ( var g = 0; g < f; g++) {
				if (g >= this.dataview.rows.length) {
					break
				}
				var k = this.dataview.rows[g];
				var u = null;
				if (!t.rows.records[k.visibleindex]) {
					u = new a(t, k)
				} else {
					u = t.rows.records[k.visibleindex];
					u.setdata(k)
				}
				u.hidden = this.hiddens[u.visibleindex];
				if (this.rowdetailstemplate) {
					u.rowdetails = this.rowdetailstemplate.rowdetails;
					u.rowdetailsheight = this.rowdetailstemplate.rowdetailsheight;
					u.rowdetailshidden = this.rowdetailstemplate.rowdetailshidden
				}
				var d = this.details[u.visibleindex];
				if (d) {
					u.rowdetails = d.rowdetails;
					u.rowdetailsheight = d.rowdetailsheight;
					u.rowdetailshidden = d.rowdetailshidden
				} else {
					if (!this.rowdetailstemplate) {
						u.rowdetails = null
					}
				}
				if (e && this.pageable && u.parentbounddata != null) {
					var r = l[u.parentbounddata.uniqueid];
					if (r != null) {
						var n = this._findgroupstate(r.uniqueid);
						if (this._setsubgroupsvisibility) {
							this._setsubgroupsvisibility(this, u.parentbounddata, !n, false)
						}
						u.hidden = this.hiddens[u.visibleindex]
					}
					if (r != null && r != undefined) {
						u.parentrow = r;
						r.subrows[r.subrows.length++] = u
					}
				}
				if (u.hidden) {
					continue
				}
				var h = k.visibleindex;
				if (!this.heights[h]) {
					this.heights[h] = this.rowsheight
				}
				u.height = this.heights[h];
				if (this.rowdetails) {
					if (u.rowdetails && !u.rowdetailshidden) {
						u.height += u.rowdetailsheight
					}
				}
				l[u.uniqueid] = u;
				q[s++] = u;
				u.top = p;
				p += u.height;
				var m = h;
				t.rows.replace(m, u)
			}
			if (this.autoheight && this.autorowheight) {
				if (this._pageviews && this._pageviews.length > 0) {
					this._pageviews[0].height = p
				}
			}
			this.rows.resumeupdate();
			if (q.length > 0) {
				this._pagescache[this.dataview.pagenum] = q
			}
		},
		_gettableheight : function() {
			if (this.tableheight != undefined) {
				return this.tableheight
			}
			var e = this.host.height();
			if (this.columnsheader) {
				var d = this.columnsheader.outerHeight();
				if (!this.showheader) {
					d = 0
				}
			}
			e -= d;
			if (this.hScrollBar[0].style.visibility == "visible") {
				e -= this.hScrollBar.outerHeight()
			}
			if (this.pageable) {
				e -= this.pager.outerHeight()
			}
			if (this._groupsheader()) {
				e -= this.groupsheader.outerHeight()
			}
			if (this.showtoolbar) {
				e -= this.toolbarheight
			}
			if (this.showstatusbar) {
				e -= this.statusbarheight
			}
			if (e > 0) {
				this.tableheight = e;
				return e
			}
			return this.host.height()
		},
		_getpagesize : function() {
			if (this.pageable) {
				return this.pagesize
			}
			if (this.virtualmode) {
				var e = Math.round(this.host.height()) + 2 * this.rowsheight;
				var d = Math.round(e / this.rowsheight);
				return d
			}
			if (this.autoheight || this.autorowheight) {
				if (this.dataview.totalrows == 0) {
					return 1
				}
				return this.dataview.totalrows
			}
			if (this.dataview.totalrows < 100 && this.dataview.totalrecords < 100 && this.dataview.totalrows > 0) {
				return this.dataview.totalrows
			}
			return 100
		},
		_calculatevirtualheight : function() {
			var n = this;
			var e = Math.round(this.host.height()) + 2 * this.rowsheight;
			realheight = this._gettableheight();
			var p = Math.round(e / this.rowsheight);
			this.heights = new Array();
			this.hiddens = new Array();
			this.details = new Array();
			this.expandedgroups = new Array();
			this.hiddenboundrows = new Array();
			this.heightboundrows = new Array();
			this.detailboundrows = new Array();
			var h = Math.max(this.dataview.totalrows, this.dataview.totalrecords);
			if (this.pageable) {
				h = this.pagesize;
				if (this.pagesize > Math.max(this.dataview.totalrows, this.dataview.totalrecords) && this.autoheight) {
					h = Math.max(this.dataview.totalrows, this.dataview.totalrecords)
				}
			}
			var l = h * this.rowsheight;
			var m = 0;
			var j = 0;
			var k = 0;
			var f = this._getpagesize();
			var d = f * this.rowsheight;
			var g = 0;
			if (!this.pageable && this.autoheight) {
				p = h
			}
			if (h + f > 0) {
				while (g <= h + f) {
					m += d;
					if (g - f < h && g >= h) {
						var o = g - h;
						if (o > 0) {
							k -= d;
							this._pageviews[j - 1] = {
								top : k,
								height : d - o * this.rowsheight
							}
						}
						break
					} else {
						this._pageviews[j++] = {
							top : k,
							height : d
						}
					}
					k = m;
					g += f
				}
			}
			this.vScrollBar.jqxScrollBar({
				value : 0
			});
			if (l > realheight && !this.autoheight) {
				this.vScrollBar.css("visibility", "visible");
				if (this.scrollmode == "deferred") {
					this.vScrollBar.jqxScrollBar({
						max : l
					})
				} else {
					this.vScrollBar.jqxScrollBar({
						max : l - realheight
					})
				}
			} else {
				this.vScrollBar.css("visibility", "hidden")
			}
			this.dataview.pagesize = f;
			this.dataview.updateview();
			return {
				visiblerecords : p,
				virtualheight : l
			}
		},
		_updatepageviews : function() {
			if (this.updating()) {
				return
			}
			this._pagescache = new Array();
			this._pageviews = new Array();
			this.tableheight = null;
			var t = this;
			var d = Math.round(this.host.height()) + 2 * this.rowsheight;
			var u = Math.round(d / this.rowsheight);
			var m = Math.max(this.dataview.totalrows, this.dataview.totalrecords);
			var p = m * this.rowsheight;
			var s = 0;
			var f = 0;
			var n = 0;
			var o = 0;
			var h = 0;
			var g = this._getpagesize();
			if (!this.pageable) {
				for ( var l = 0; l < m; l++) {
					var r = {
						index : l,
						height : this.heights[l],
						hidden : this.hiddens[l],
						details : this.details[l]
					};
					if (this.heights[l] == undefined) {
						this.heights[l] = this.rowsheight;
						r.height = this.rowsheight
					}
					if (this.hiddens[l] == undefined) {
						this.hiddens[l] = false;
						r.hidden = false
					}
					if (this.details[l] == undefined) {
						this.details[l] = null
					}
					if (r.height != t.rowsheight) {
						p -= t.rowsheight;
						p += r.height
					}
					if (r.hidden) {
						p -= r.height
					} else {
						f += r.height;
						var j = 0;
						if (this.rowdetails) {
							if (this.rowdetailstemplate) {
								if (!r.details) {
									r.details = this.rowdetailstemplate
								}
							}
							if (r.details && r.details.rowdetails && !r.details.rowdetailshidden) {
								j = r.details.rowdetailsheight;
								f += j;
								p += j
							}
						}
						s += r.height + j
					}
					h++;
					if (h >= g || l == m - 1) {
						this._pageviews[n++] = {
							top : o,
							height : f
						};
						f = 0;
						o = s;
						h = 0
					}
				}
			} else {
				if (this._updatepagedview) {
					p = this._updatepagedview(m, p, 0)
				}
				if (this.autoheight) {
					this._arrange()
				}
			}
			var e = this._gettableheight();
			if (p > e) {
				if (this.pageable && this.gotopage) {
					p = this._pageviews[0].height;
					if (p < 0) {
						p = this._pageviews[0].height
					}
				}
				if (this.vScrollBar.css("visibility") != "visible") {
					this.vScrollBar.css("visibility", "visible")
				}
				if (p <= e || this.autoheight) {
					this.vScrollBar.css("visibility", "hidden")
				}
				if (p - e > 0) {
					if (this.scrollmode != "deferred") {
						var q = p - e;
						this.vScrollBar.jqxScrollBar({
							max : q
						})
					}
				} else {
					this.vScrollBar.jqxScrollBar({
						value : 0,
						max : p
					})
				}
			} else {
				if (!this._loading) {
					this.vScrollBar.css("visibility", "hidden")
				}
				this.vScrollBar.jqxScrollBar({
					value : 0
				})
			}
			this._arrange();
			if (this.autoheight) {
				u = Math.round(this.host.height() / this.rowsheight)
			}
			this.virtualsizeinfo = {
				visiblerecords : u,
				virtualheight : p
			}
		},
		updatebounddata : function(d) {
			this.databind(this.source, d)
		},
		refreshdata : function() {
			this._refreshdataview();
			this.render()
		},
		_updatevscrollbarmax : function() {
			if (this._pageviews && this._pageviews.length > 0) {
				var f = this._pageviews[0].height;
				var e = this._gettableheight();
				if (f > e) {
					if (this.pageable && this.gotopage) {
						f = this._pageviews[0].height;
						if (f < 0) {
							f = this._pageviews[0].height
						}
					}
					if (this.vScrollBar.css("visibility") != "visible") {
						this.vScrollBar.css("visibility", "visible")
					}
					if (f <= e || this.autoheight) {
						this.vScrollBar.css("visibility", "hidden")
					}
					if (f - e > 0) {
						var d = f - e;
						this.vScrollBar.jqxScrollBar({
							max : d
						})
					} else {
						this.vScrollBar.jqxScrollBar({
							value : 0,
							max : f
						})
					}
				} else {
					this.vScrollBar.css("visibility", "hidden");
					this.vScrollBar.jqxScrollBar({
						value : 0
					})
				}
			}
		},
		_refreshdataview : function() {
			this.dataview.refresh()
		},
		refresh : function(d) {
			if (d != true) {
				if (this.virtualsizeinfo != null) {
					this._cellscache = new Array();
					this._renderrows(this.virtualsizeinfo);
					this._updatesize()
				}
			}
		},
		render : function() {
			this._render(true, true, true, true)
		},
		invalidate : function() {
			if (this.virtualsizeinfo) {
				this._updatecolumnwidths();
				this._updatecellwidths();
				this._renderrows(this.virtualsizeinfo)
			}
		},
		clear : function() {
			this.databind(null);
			this.render()
		},
		_render : function(g, h, f, d, e) {
			if (this.dataview == null) {
				return
			}
			if (this.editcell != null && this.endcelledit) {
				this.endcelledit(this.editcell.row, this.editcell.column, true, false)
			}
			this.validationpopup = null;
			this._removeHandlers();
			this._addHandlers();
			this._initializeRows();
			this._requiresupdate = h != undefined ? h : true;
			if (f) {
				if (!this._requiresupdate) {
					if (d != false) {
						this._initmenu()
					}
				}
				if (this.columns == null) {
					this.columns = new b.jqx.collection(this.element)
				} else {
					this._initializeColumns()
				}
			}
			this.tableheight = null;
			this._pagescache = new Array();
			this._pageviews = new Array();
			this.visiblerows = new Array();
			this.hittestinfo = new Array();
			if (this._requiresupdate) {
				this._clearcaches();
				if (d != false) {
					this._initmenu()
				}
			}
			this.virtualsizeinfo = null;
			this.prerenderrequired = true;
			if ((this.groupable && this.groups.length > 0 && this.rowdetails) || (this.rowdetails)) {
				if (this.gridcontent) {
					this._rowdetailscache = new Array();
					this._rowdetailselementscache = new Array();
					this.detailboundrows = new Array();
					this.details = new Array();
					b.jqx.utilities.html(this.gridcontent, "");
					this.gridcontent = null
				}
			}
			if (f) {
				if (this.filterrow) {
					this.filterrow.detach()
				}
				b.jqx.utilities.html(this.content, "");
				this.columnsheader = this.columnsheader || b('<div style="overflow: hidden;"></div>');
				this.columnsheader.remove();
				this.columnsheader.addClass(this.toTP("jqx-widget-header"));
				this.columnsheader.addClass(this.toTP("jqx-grid-header"))
			} else {
				if (this.gridcontent) {
					b.jqx.utilities.html(this.gridcontent, "")
				}
			}
			if (!this.showheader) {
				this.columnsheader.css("display", "none")
			} else {
				if (this.columnsheader) {
					this.columnsheader.css("display", "block")
				}
			}
			this.gridcontent = this.gridcontent || b('<div style="width: 100%; overflow: hidden; position: absolute;"></div>');
			this.gridcontent.remove();
			if (this.showfilterrow && this.filterable) {
				this.columnsheader.height(this.columnsheight + this.filterrowheight)
			} else {
				this.columnsheader.height(this.columnsheight)
			}
			this.content.append(this.columnsheader);
			this.content.append(this.gridcontent);
			this._arrange();
			if (this._initgroupsheader) {
				this._initgroupsheader()
			}
			this.selectionarea = this.selectionarea || b("<div style='z-index: 99999; visibility: hidden; position: absolute;'></div>");
			this.selectionarea.addClass(this.toThemeProperty("jqx-grid-selectionarea"));
			this.selectionarea.addClass(this.toThemeProperty("jqx-fill-state-pressed"));
			this.content.append(this.selectionarea);
			this.tableheight = null;
			this.rendergridcontent(false, f);
			if (this.groups.length > 0 && this.groupable) {
				this.suspendgroupevents = true;
				if (this.collapseallgroups) {
					if (!this.groupsexpandedbydefault) {
						this.collapseallgroups(false);
						this._updatescrollbarsafterrowsprerender()
					} else {
						this.expandallgroups(false)
					}
				}
				this.suspendgroupevents = false
			}
			if (this.pageable && this.updatepagerdetails) {
				this.updatepagerdetails();
				if (this.autoheight) {
					this._updatepageviews();
					if (this.autorowheight) {
						this._renderrows(this.virtualsizeinfo)
					}
				}
			}
			if (this.showaggregates && this._updateaggregates) {
				this._updateaggregates()
			}
			this._addoverlayelement();
			if (this.scrollmode == "deferred") {
				this._addscrollelement()
			}
			if (this.showfilterrow && this.filterable && this.filterrow && (e == undefined || e == true)) {
				this._updatelistfilters()
			}
			if (this.rendered) {
				this.rendered("full")
			}
		},
		_addoverlayelement : function() {
			var d = b.jqx.utilities.getBrowser();
			if ((d.browser == "msie" && parseInt(d.version) < 9) || this.isTouchDevice()) {
				if (this._overlayElement) {
					this._overlayElement.remove()
				}
				this._overlayElement = b("<div style='visibility: hidden; position: absolute; width: 100%; height: 100%;'></div>");
				this._overlayElement.css("background", "white");
				this._overlayElement.css("z-index", 18000);
				this._overlayElement.css("opacity", 0.001);
				if (this.isTouchDevice()) {
					this.table.prepend(this._overlayElement);
					this._overlayElement.css("visibility", "visible");
					if (this.groupable || this.rowdetails) {
						this._overlayElement.css("left", 30 * (this.groups.length + (this.rowdetails ? 1 : 0)))
					}
					if (this.autoheight) {
						this._overlayElement.remove()
					}
				} else {
					this.content.prepend(this._overlayElement)
				}
			}
			this._updateTouchScrolling()
		},
		_addscrollelement : function() {
			if (this._scrollelement) {
				this._scrollelement.remove()
			}
			if (this._scrollelementoverlay) {
				this._scrollelementoverlay.remove()
			}
			this._scrollelementoverlay = b("<div style='visibility: hidden; position: absolute; width: 100%; height: 100%;'></div>");
			this._scrollelementoverlay.css("background", "black");
			this._scrollelementoverlay.css("z-index", 18000);
			this._scrollelementoverlay.css("opacity", 0.1);
			this._scrollelement = b("<span style='visibility: hidden; top: 50%; right: 10px; position: absolute;'></span>");
			this._scrollelement.css("z-index", 18005);
			this._scrollelement.addClass(this.toThemeProperty("jqx-button"));
			this._scrollelement.addClass(this.toThemeProperty("jqx-fill-state-normal"));
			this._scrollelement.addClass(this.toThemeProperty("jqx-rc-all"));
			this._scrollelement.addClass(this.toThemeProperty("jqx-shadow"));
			this.content.prepend(this._scrollelement);
			this.content.prepend(this._scrollelementoverlay)
		},
		rendergridcontent : function(d, f) {
			if (this.updating()) {
				return false
			}
			if (d == undefined || d == null) {
				d = false
			}
			this._requiresupdate = d;
			var h = this.prerenderrequired;
			if (this.prerenderrequired) {
				this._arrange()
			}
			var g = this;
			var f = f;
			if (f == null || f == undefined) {
				f = true
			}
			this.tableheight = null;
			g.virtualsizeinfo = g.virtualsizeinfo || g._calculatevirtualheight();
			if (g.pageable && !g.autoheight) {
				if (g.dataview.totalrows < g.pagesize) {
					g._requiresupdate = true
				}
			}
			if (f) {
				g._rendercolumnheaders()
			} else {
				if (this._rendersortcolumn) {
					this._rendersortcolumn()
				}
				if (this._renderfiltercolumn) {
					this._renderfiltercolumn()
				}
			}
			g._renderrows(g.virtualsizeinfo);
			if (this.gridcontent[0].scrollTop != 0) {
				this.gridcontent[0].scrollTop = 0
			}
			if (this.gridcontent[0].scrollLeft != 0) {
				this.gridcontent[0].scrollLeft = 0
			}
			if (h) {
				var e = this.tableheight;
				this._arrange();
				if (e != this.tableheight && this.autoheight) {
					g._renderrows(g.virtualsizeinfo)
				}
			}
			if (this.autosavestate) {
				if (this.initializedcall != null) {
					if (this.savestate) {
						this.savestate()
					}
				}
			}
			return true
		},
		_updatecolumnwidths : function() {
			var j = this.host.width();
			var d = j;
			var i = "";
			if (this.columns == undefined || this.columns.records == undefined) {
				return
			}
			var l = this;
			b.each(this.columns.records, function(m, n) {
				if (!(this.hidden && this.hideable)) {
					if (this.width.toString().indexOf("%") != -1 || this._percentagewidth != undefined) {
						var n = 0;
						var o = l.vScrollBar[0].style.visibility == "hidden" ? 0 : l.scrollbarsize + 5;
						n = parseInt(this.width) * d / 100;
						if (this._percentagewidth != undefined) {
							n = parseInt(this._percentagewidth) * (d - o) / 100
						}
						if (n < this.minwidth && this.minwidth != "auto") {
							n = this.minwidth
						}
						if (n > this.maxwidth && this.maxwidth != "auto") {
							n = this.maxwidth
						}
						j -= Math.round(n)
					} else {
						if (this.width != "auto" && !this._width) {
							j -= this.width
						} else {
							i += this.text
						}
					}
				}
			});
			var e = this._gettableheight();
			if (!this.autoheight) {
				if (this.virtualsizeinfo && this.virtualsizeinfo.virtualheight > e) {
					if (this.groupable && this.groups.length > 0) {
						if (this.dataview && this.dataview.loadedrootgroups && !this.groupsexpandedbydefault) {
							var k = this.dataview.loadedrootgroups.length * this.rowsheight;
							if (k > e) {
								j -= this.scrollbarsize + 5;
								d -= this.scrollbarsize + 5
							} else {
								if (this.vScrollBar.css("visibility") == "visible") {
									j -= this.scrollbarsize + 5;
									d -= this.scrollbarsize + 5
								}
							}
						} else {
							j -= this.scrollbarsize + 5;
							d -= this.scrollbarsize + 5
						}
					} else {
						j -= this.scrollbarsize + 5;
						d -= this.scrollbarsize + 5
					}
				}
			}
			var g = this.columnsheader.find("#columntable" + this.element.id);
			if (g.length == 0) {
				return
			}
			var h = g.find(".jqx-grid-column-header");
			var f = 0;
			b.each(this.columns.records, function(n, r) {
				var p = b(h[n]);
				var m = false;
				var q = this.width;
				if (this.width.toString().indexOf("%") != -1 || this._percentagewidth != undefined) {
					if (this._percentagewidth != undefined) {
						q = parseInt(this._percentagewidth) * d / 100
					} else {
						q = parseInt(this.width) * d / 100
					}
					m = true
				}
				if (this.width != "auto" && !this._width && !m) {
					if (parseInt(p[0].style.width) != this.width) {
						p.width(this.width)
					}
				} else {
					if (m) {
						if (q < this.minwidth && this.minwidth != "auto") {
							q = this.minwidth;
							this.width = q
						}
						if (q > this.maxwidth && this.maxwidth != "auto") {
							q = this.maxwidth;
							this.width = q
						}
						if (parseInt(p[0].style.width) != q) {
							p.width(q);
							this.width = q
						}
					} else {
						var o = Math.round(j * (this.text.length / i.length));
						if (isNaN(o)) {
							o = this.minwidth
						}
						if (o < 0) {
							$element = b("<span>" + this.text + "</span>");
							b(document.body).append($element);
							o = 10 + $element.width();
							$element.remove()
						}
						if (o < this.minwidth) {
							o = this.minwidth
						}
						if (o > this.maxwidth) {
							o = this.maxwidth
						}
						this._width = "auto";
						this.width = o;
						p.width(this.width)
					}
				}
				if (parseInt(p[0].style.left) != f) {
					p.css("left", f)
				}
				if (!(this.hidden && this.hideable)) {
					f += this.width
				}
				this._requirewidthupdate = true
			});
			this.columnsheader.width(2 + f);
			g.width(this.columnsheader.width());
			if (this.showfilterrow && this.filterrow) {
				this.filterrow.width(this.columnsheader.width());
				this._updatefilterrowui()
			}
		},
		_rendercolumnheaders : function() {
			var q = this;
			if (!this.prerenderrequired) {
				if (this._rendersortcolumn) {
					this._rendersortcolumn()
				}
				if (this._renderfiltercolumn) {
					this._renderfiltercolumn()
				}
				if (this.showfilterrow && this.filterrow) {
					this.filterrow.width(this.columnsheader.width());
					this._updatefilterrowui()
				}
				return
			}
			this._columnsbydatafield = new Array();
			this.columnsheader.find("#columntable" + this.element.id).remove();
			var h = b('<div id="columntable' + this.element.id + '" style="height: 100%; position: relative;"></div>');
			h[0].cells = new Array();
			var t = 0;
			var e = 0;
			var n = "";
			var y = this.host.width();
			var m = y;
			var d = new Array();
			var s = new Array();
			b.each(this.columns.records, function(j, k) {
				if (!(this.hidden && this.hideable)) {
					if (this.width != "auto" && !this._width) {
						if (this.width < this.minwidth && this.minwidth != "auto") {
							y -= this.minwidth
						} else {
							if (this.width > this.maxwidth && this.maxwidth != "auto") {
								y -= this.maxwidth
							} else {
								if (this.width.toString().indexOf("%") != -1) {
									var k = 0;
									k = parseInt(this.width) * m / 100;
									if (k < this.minwidth && this.minwidth != "auto") {
										k = this.minwidth
									}
									if (k > this.maxwidth && this.maxwidth != "auto") {
										k = this.maxwidth
									}
									y -= k
								} else {
									if (typeof this.width == "string") {
										this.width = parseInt(this.width)
									}
									y -= this.width
								}
							}
						}
					} else {
						n += this.text
					}
				}
				if (this.pinned) {
					d[d.length] = this
				} else {
					s[s.length] = this
				}
			});
			if (!this.rtl) {
				for ( var v = 0; v < d.length; v++) {
					this.columns.replace(v, d[v])
				}
				for ( var u = 0; u < s.length; u++) {
					this.columns.replace(d.length + u, s[u])
				}
			} else {
				var r = 0;
				d.reverse();
				for ( var v = this.columns.records.length - 1; v >= this.columns.records.length - d.length; v--) {
					this.columns.replace(v, d[r++])
				}
				for ( var u = 0; u < s.length; u++) {
					this.columns.replace(u, s[u])
				}
			}
			var g = this.headerZIndex;
			var l = q.groupable ? q.groups.length : 0;
			if (this.rowdetails && this.showrowdetailscolumn) {
				l++
			}
			var f = q.columnsheader.height();
			if (this.showfilterrow) {
				f = this.columnsheight
			}
			var o = this._gettableheight();
			if (this.virtualsizeinfo && this.virtualsizeinfo.virtualheight > o) {
				if (this.groupable && this.groups.length > 0) {
					if (this.dataview && this.dataview.loadedrootgroups && !this.groupsexpandedbydefault) {
						var w = this.dataview.loadedrootgroups.length * this.rowsheight;
						if (w > o) {
							y -= this.scrollbarsize + 5;
							m -= this.scrollbarsize + 5
						}
					} else {
						y -= this.scrollbarsize + 5;
						m -= this.scrollbarsize + 5
					}
				} else {
					if (!this.autoheight) {
						y -= this.scrollbarsize + 5;
						m -= this.scrollbarsize + 5
					}
				}
			}
			b.each(this.columns.records, function(P, M) {
				var R = q.toTP("jqx-grid-column-header") + " " + q.toTP("jqx-widget-header");
				if (q.rtl) {
					R += " " + q.toTP("jqx-grid-column-header-rtl")
				}
				var z = b('<div style="position: absolute; height: 100%;" class="' + R + '"></div>');
				this.uielement = z;
				if (this.classname != "" && this.classname) {
					z.addClass(this.classname)
				}
				if (!q.rtl) {
					z.css("z-index", g--)
				} else {
					z.css("z-index", g++)
				}
				var G = this.width;
				var I = false;
				if (this.width.toString().indexOf("%") != -1 || this._percentagewidth != undefined) {
					if (this._percentagewidth != undefined) {
						G = parseInt(this._percentagewidth) * m / 100
					} else {
						G = parseInt(this.width) * m / 100
					}
					I = true
				}
				if (this.width != "auto" && !this._width && !I) {
					if (G < this.minwidth && this.minwidth != "auto") {
						G = this.minwidth
					}
					if (G > this.maxwidth && this.maxwidth != "auto") {
						G = this.maxwidth
					}
					z.width(G)
				} else {
					if (I) {
						if (G < this.minwidth && this.minwidth != "auto") {
							G = this.minwidth
						}
						if (G > this.maxwidth && this.maxwidth != "auto") {
							G = this.maxwidth
						}
						if (this._percentagewidth == undefined || this.width.toString().indexOf("%") != -1) {
							this._percentagewidth = this.width
						}
						z.width(G);
						this.width = G
					} else {
						var L = Math.round(y * (this.text.length / n.length));
						if (isNaN(L)) {
							L = this.minwidth
						}
						if (L < 0) {
							$element = b("<span>" + this.text + "</span>");
							b(document.body).append($element);
							L = 10 + $element.width();
							$element.remove()
						}
						if (L < this.minwidth) {
							L = this.minwidth
						}
						if (L > this.maxwidth) {
							L = this.maxwidth
						}
						this._width = "auto";
						this.width = L;
						G = this.width;
						z.width(this.width)
					}
				}
				if (this.hidden && this.hideable) {
					z.css("display", "none")
				}
				var k = b('<div style="height: 100%; width: 100%;"></div>');
				var C = b('<div style="display: none; left: 100%; top: 0%; position: absolute;"></div>');
				var F = b('<div style="width: 100%; height:100%;"></div>');
				F.addClass(q.toTP("jqx-grid-column-menubutton"));
				if (q.rtl) {
					F.addClass(q.toTP("jqx-grid-column-menubutton-rtl"))
				}
				F.appendTo(C);
				C.height(f);
				if (!q.enableanimations) {
					C.css("margin-left", -16)
				}
				if (q.rtl) {
					C.css("left", "0px")
				}
				var H = b('<div class="sortasc" style="float: right; display: none; width: 16px;"><div style="width: 100%; height:100%;"></div></div>');
				var K = b('<div class="sortdesc" style="float: right; display: none; width: 16px;"><div style="width: 100%; height:100%;"></div></div>');
				var O = b('<div class="filtericon" style="float: right; display: none; width: 16px;"><div style="width: 100%; height:100%;"></div></div>');
				if (!q.autoshowfiltericon && this.filterable) {
					O.css("display", "block")
				}
				H.height(f);
				K.height(f);
				O.height(f);
				H.find("div").addClass(q.toTP("jqx-grid-column-sortascbutton"));
				K.find("div").addClass(q.toTP("jqx-grid-column-sortdescbutton"));
				O.find("div").addClass(q.toTP("jqx-grid-column-filterbutton"));
				this.sortasc = H[0];
				this.sortdesc = K[0];
				this.filtericon = O[0];
				this.columnsmenu = C[0];
				h[0].cells[P] = z[0];
				C.width(q.columnsmenuwidth);
				var B = q.columnsmenu;
				var p = false;
				var N = false;
				var J = (q.groupable && l > 0 && t < l) || (q.rowdetails && t < l);
				if (q.rtl) {
					J = (q.groupable && l > 0 && t < l) || (q.rowdetails && t < l);
					J &= P > q.columns.records.length - 1 - l
				}
				if (J) {
					t++;
					B &= false;
					this.sortable = false;
					this.editable = false;
					N = true
				} else {
					var D = this.renderer != null ? this.renderer(this.text, this.align) : q._rendercolumnheader(this.text, this.align);
					if (D == null) {
						D = q._rendercolumnheader(this.text, this.align)
					}
					if (this.renderer != null) {
						D = b(D)
					}
					B &= true;
					p = true
				}
				k.append(D);
				if (D != null) {
					var E = b('<div class="iconscontainer" style="margin-left: -32px; display: block; position: absolute; left: 100%; top: 0%; width: 32px;"></div>');
					C.addClass(q.toTP("jqx-widget-header"));
					E.height(f);
					k.append(E);
					E.append(O);
					E.append(H);
					E.append(K);
					K.addClass(q.toTP("jqx-widget-header"));
					H.addClass(q.toTP("jqx-widget-header"));
					O.addClass(q.toTP("jqx-widget-header"));
					this.iconscontainer = E;
					if (q.rtl) {
						E.css("margin-left", "0px");
						E.css("left", "0px");
						H.css("float", "left");
						O.css("float", "left");
						K.css("float", "left")
					}
				}
				if (B) {
					q._handlecolumnsmenu(q, k, z, C, this);
					if (!this.menu) {
						C.hide()
					}
				}
				z.append(k);
				h.append(z);
				if (q.groupable && p) {
					z[0].id = q.dataview.generatekey();
					if (q._handlecolumnstogroupsdragdrop) {
						q._handlecolumnstogroupsdragdrop(this, z)
					} else {
						alert("jqxgrid.grouping.js is not loaded")
					}
				}
				if (q.columnsreorder && this.draggable && q._handlecolumnsdragreorder) {
					q._handlecolumnsdragreorder(this, z)
				}
				var Q = this;
				q.addHandler(z, "click", function(i) {
					if (q.sorttogglestates > 0 && q._togglesort) {
						if (!q._loading) {
							q._togglesort(Q)
						}
					}
					i.preventDefault();
					q._raiseEvent(7, {
						column : Q.getcolumnproperties(),
						datafield : Q.datafield,
						originalEvent : i
					})
				});
				if (Q.resizable && q.columnsresize && !N) {
					var A = false;
					var j = "mousemove";
					if (q.isTouchDevice()) {
						A = true;
						j = b.jqx.mobile.getTouchEventName("touchstart")
					}
					q.addHandler(z, j, function(S) {
						var i = parseInt(S.pageX);
						var U = 5;
						var X = parseInt(z.offset().left);
						if (q.hasTransform) {
							X = b.jqx.utilities.getOffset(z).left
						}
						if (q._handlecolumnsresize) {
							if (A) {
								var T = q.getTouches(S);
								var W = T[0];
								i = W.pageX;
								U = 40;
								if (i >= X + Q.width - U) {
									q.resizablecolumn = {
										columnelement : z,
										column : Q
									};
									z.css("cursor", "col-resize")
								} else {
									z.css("cursor", "");
									q.resizablecolumn = null
								}
								return true
							}
							var V = Q.width;
							if (q.rtl) {
								V = 0
							}
							if (i >= X + V - U) {
								if (i <= X + V + U) {
									q.resizablecolumn = {
										columnelement : z,
										column : Q
									};
									z.css("cursor", "col-resize");
									return false
								} else {
									z.css("cursor", "");
									q.resizablecolumn = null
								}
							} else {
								z.css("cursor", "");
								q.resizablecolumn = null
							}
						}
					})
				}
				z.css("left", e);
				if (!(this.hidden && this.hideable)) {
					e += G
				}
				if (Q.rendered) {
					Q.rendered(D);
					if (E != null) {
						E.hide()
					}
				}
			});
			if (e > 0) {
				this.columnsheader.width(2 + e)
			} else {
				this.columnsheader.width(e)
			}
			this.columnsrow = h;
			q.columnsheader.append(h);
			if (this.showfilterrow && this._updatefilterrow) {
				h.height(this.columnsheight);
				if (!this.filterrow) {
					var x = b("<div></div>");
					x[0].id = "filterrow." + this.element.id;
					x.height(this.filterrowheight);
					this.filterrow = x
				}
				this.columnsheader.append(this.filterrow);
				this._updatefilterrow()
			}
			h.width(e);
			if (this._handlecolumnsdragdrop) {
				this._handlecolumnsdragdrop()
			}
			if (this._handlecolumnsreorder) {
				this._handlecolumnsreorder()
			}
			if (this._rendersortcolumn) {
				this._rendersortcolumn()
			}
			if (this._renderfiltercolumn) {
				this._renderfiltercolumn()
			}
			if (this._handlecolumnsresize) {
				this._handlecolumnsresize()
			}
		},
		_handlecolumnsmenu : function(o, f, g, j, l) {
			o.dragmousedown = null;
			j[0].id = o.dataview.generatekey();
			f.append(j);
			g[0].columnsmenu = j[0];
			l.element = g[0];
			var k = 16;
			var n = function() {
				if (!l.menu) {
					return false
				}
				if (!o.resizing) {
					if (o.menuitemsarray.length > 0) {
						if (!o.enableanimations) {
							j.css("display", "block");
							var p = !o.rtl ? -48 : 16;
							l.iconscontainer.css("margin-left", p + "px")
						} else {
							j.css("display", "block");
							j.stop();
							l.iconscontainer.stop();
							if (!o.rtl) {
								j.css("margin-left", "0px");
								j.animate({
									"margin-left" : -k
								}, "fast", function() {
									j.css("display", "block")
								})
							} else {
								j.css("margin-left", -k);
								j.animate({
									"margin-left" : "0px"
								}, "fast", function() {
									j.css("display", "block")
								})
							}
							var p = !o.rtl ? -48 : 16;
							l.iconscontainer.animate({
								"margin-left" : p
							}, "fast")
						}
					}
				}
			};
			o.addHandler(g, "mouseenter", function(p) {
				if (l.menu && o.autoshowcolumnsmenubutton) {
					n()
				}
			});
			if (!o.autoshowcolumnsmenubutton) {
				j.css("display", "block");
				var e = !o.rtl ? -48 : 16;
				l.iconscontainer.css("margin-left", e + "px");
				if (!o.rtl) {
					j.css({
						"margin-left" : -k
					})
				} else {
					j.css({
						"margin-left" : "0px"
					})
				}
			}
			o.addHandler(g, "mouseleave", function(p) {
				if (o.menuitemsarray.length > 0 && l.menu) {
					var r = b.data(document.body, "contextmenu" + o.element.id);
					if (r != undefined && j[0].id == r.columnsmenu.id) {
						return
					}
					if (o.autoshowcolumnsmenubutton) {
						if (!o.enableanimations) {
							j.css("display", "none");
							var q = !o.rtl ? -32 : 0;
							l.iconscontainer.css("margin-left", q + "px")
						} else {
							if (!o.rtl) {
								j.css("margin-left", -k)
							} else {
								j.css("margin-left", "0px")
							}
							j.stop();
							l.iconscontainer.stop();
							if (!o.rtl) {
								j.animate({
									"margin-left" : 0
								}, "fast", function() {
									j.css("display", "none")
								})
							} else {
								j.animate({
									"margin-left" : -k
								}, "fast", function() {
									j.css("display", "none")
								})
							}
							var q = !o.rtl ? -32 : 0;
							l.iconscontainer.animate({
								"margin-left" : q
							}, "fast")
						}
					}
				}
			});
			var i = true;
			var d = "";
			var h = b(l.filtericon);
			o.addHandler(j, "mousedown", function(p) {
				i = !b.data(o.gridmenu[0], "contextMenuOpened" + o.gridmenu[0].id);
				d = b.data(document.body, "contextmenu" + o.element.id);
				if (d != null) {
					d = d.column.datafield
				}
			});
			o.addHandler(h, "mousedown", function(p) {
				i = !b.data(o.gridmenu[0], "contextMenuOpened" + o.gridmenu[0].id);
				d = b.data(document.body, "contextmenu" + o.element.id);
				if (d != null) {
					d = d.column.datafield
				}
			});
			var m = function() {
				if (!l.menu) {
					return false
				}
				var s = j.offset();
				var y = j.height();
				if (!i) {
					i = true;
					if (d == l.datafield) {
						o._closemenu();
						return false
					}
				}
				var v = o.host.offset();
				if (o.hasTransform) {
					v = b.jqx.utilities.getOffset(o.host);
					s = b.jqx.utilities.getOffset(j)
				}
				if (v.left + o.host.width() > parseInt(s.left) + o.gridmenu.width()) {
					o.gridmenu.jqxMenu("open", s.left, s.top + y)
				} else {
					o.gridmenu.jqxMenu("open", j.width() + s.left - o.gridmenu.width(), s.top + y)
				}
				if (o.gridmenu.width() < 100) {
					o._arrangemenu()
				}
				o._hasOpenedMenu = true;
				var w = o._getmenuitembyindex(0);
				var p = o._getmenuitembyindex(1);
				var A = o._getmenuitembyindex(2);
				var x = o._getmenuitembyindex(3);
				var q = o._getmenuitembyindex(4);
				var B = o._getmenuitembyindex(5);
				if (w != null && p != null && A != null) {
					var t = l.sortable && o.sortable;
					o.gridmenu.jqxMenu("disable", w.id, !t);
					o.gridmenu.jqxMenu("disable", p.id, !t);
					o.gridmenu.jqxMenu("disable", A.id, !t);
					if (l.datafield) {
						if (o.sortcolumn == l.datafield) {
							var u = o.getsortinformation();
							if (t) {
								if (u.sortdirection.ascending) {
									o.gridmenu.jqxMenu("disable", w.id, true)
								} else {
									o.gridmenu.jqxMenu("disable", p.id, true)
								}
							}
						} else {
							o.gridmenu.jqxMenu("disable", A.id, true)
						}
					}
				}
				if (x != null && q != null) {
					if (!o.groupable || !l.groupable) {
						o.gridmenu.jqxMenu("disable", q.id, true);
						o.gridmenu.jqxMenu("disable", x.id, true)
					} else {
						if (o.groups && o.groups.indexOf(l.datafield) != -1) {
							o.gridmenu.jqxMenu("disable", x.id, true);
							o.gridmenu.jqxMenu("disable", q.id, false)
						} else {
							o.gridmenu.jqxMenu("disable", x.id, false);
							o.gridmenu.jqxMenu("disable", q.id, true)
						}
					}
				}
				if (B != null) {
					o._updatefilterpanel(o, B, l);
					var r = 0;
					if (o.sortable && o._togglesort && o.showsortmenuitems) {
						r += 3
					}
					if (o.groupable && o.addgroup && o.showgroupmenuitems) {
						r += 2
					}
					var z = r * 27 + 3;
					if (b.jqx.browser.msie && b.jqx.browser.version < 8) {
						z += 20;
						b(B).height(190)
					}
					if (o.filterable && o.showfiltermenuitems) {
						if (!l.filterable) {
							o.gridmenu.height(z);
							b(B).css("display", "none")
						} else {
							o.gridmenu.height(z + 176);
							b(B).css("display", "block")
						}
					}
				}
				b.data(document.body, "contextmenu" + o.element.id, {
					column : l,
					columnsmenu : j[0]
				})
			};
			o.addHandler(h, "click", function(p) {
				if (!l.menu) {
					return false
				}
				if (!o.showfilterrow) {
					n();
					m()
				}
				return false
			});
			o.addHandler(j, "click", function(p) {
				if (!l.menu) {
					return false
				}
				m();
				return false
			})
		},
		_removecolumnhandlers : function(h) {
			var e = this;
			var f = b(h.element);
			if (f.length > 0) {
				e.removeHandler(f, "mouseenter");
				e.removeHandler(f, "mouseleave");
				var g = b(h.filtericon);
				e.removeHandler(g, "mousedown");
				e.removeHandler(g, "click");
				e.removeHandler(f, "click");
				if (f[0].columnsmenu) {
					var d = b(f[0].columnsmenu);
					e.removeHandler(d, "click");
					e.removeHandler(d, "mousedown")
				}
			}
		},
		_rendercolumnheader : function(f, g) {
			var e = "4px";
			if (this.columnsheight != 25) {
				e = (this.columnsheight / 2 - this._columnheight / 2) + "px"
			}
			if (this.enableellipsis) {
				return b('<div style="overflow: hidden; text-overflow: ellipsis; text-align: ' + g + "; margin-left: 4px; margin-right: 2px; margin-top: " + e + ';"><span style="text-overflow: ellipsis; cursor: default;">' + f + "</span></div>")
			}
			if (g == "center") {
				return b('<div style="text-align: center; margin-top: ' + e + ';"><a href="#">' + f + "</a></div>")
			}
			var d = b('<a style="margin-top: ' + e + "; float: " + g + ';" href="#">' + f + "</a>");
			return d
		},
		_renderrows : function(e) {
			var l = this;
			if ((this.pageable || this.groupable) && this.autoheight) {
				if (this.table != null && this.table[0].rows != null && this.table[0].rows.length < this.dataview.rows.length) {
					l.prerenderrequired = true
				}
			}
			if (!this.pageable && this.autoheight && (this.virtualmode || this.unboundmode)) {
				var j = this.source.totalrecords;
				if (!isNaN(j)) {
					if (this.table != null && this.table[0].rows != null && this.table[0].rows.length != j) {
						l.prerenderrequired = true
					}
				}
			}
			if (this.autoheight && !l.prerenderrequired) {
				if (this.table && this.table[0].rows) {
					if (this.table[0].rows.length < this.dataview.records.length) {
						if (this.pageable && this.table[0].rows.length < this.dataview.pagesize) {
							l.prerenderrequired = true
						} else {
							if (!this.pageable) {
								l.prerenderrequired = true
							}
						}
					}
					if (this.table[0].rows.length < this.dataview.cachedrecords.length) {
						if (this.pageable && this.table[0].rows.length < this.dataview.pagesize) {
							l.prerenderrequired = true
						} else {
							if (!this.pageable) {
								l.prerenderrequired = true
							}
						}
					}
				}
			}
			l._prerenderrows(e);
			if (l._requiresupdate) {
				l._requiresupdate = false;
				l._updatepageviews()
			}
			var k = function() {
				if (l._loading) {
					return
				}
				if (l.WinJS) {
					MSApp.execUnsafeLocalFunction(function() {
						l._rendervisualrows()
					})
				} else {
					l._rendervisualrows()
				}
				if (l.virtualmode && l.showaggregates && l._updateaggregates) {
					l.refreshaggregates()
				}
			};
			if (this.virtualmode) {
				var f = function() {
					if (l.rendergridrows) {
						var p = l._startboundindex;
						if (p == undefined) {
							p = 0
						}
						var n = p + 1 + l.dataview.pagesize;
						if (p != null && n != null) {
							var o = l.source._source ? true : false;
							var q = !o ? l.source.recordstartindex : l.source._source.recordstartindex;
							if (q != p) {
								if (!o) {
									l.source.recordstartindex = p;
									l.source.recordendindex = n
								} else {
									l.source._source.recordstartindex = p;
									l.source._source.recordendindex = n
								}
								l.updatebounddata()
							}
						}
					}
				};
				if (this.loadondemand) {
					f();
					this.loadondemand = false
				}
				var g = this._browser == undefined ? this._isIE10() : this._browser;
				if (this.editable && this.editcell && !this.vScrollInstance.isScrolling() && !this.hScrollInstance.isScrolling()) {
					k()
				} else {
					if (this.autoheight) {
						k()
					} else {
						if (g || b.jqx.browser.mozilla || (navigator && navigator.userAgent.indexOf("Safari") != -1)) {
							if (this._scrolltimer != null) {
								clearTimeout(this._scrolltimer)
							}
							this._scrolltimer = setTimeout(function() {
								k()
							}, 5)
						} else {
							k()
						}
					}
				}
			} else {
				if (this.scrollmode == "deferred" && (this.hScrollInstance.isScrolling() || this.vScrollInstance.isScrolling())) {
					if (this._scrolltimer != null) {
						clearInterval(this._scrolltimer)
					}
					var m = this._getfirstvisualrow();
					if (m != null) {
						var i = function(s) {
							if (m == null) {
								return ""
							}
							var r = "<table>";
							var p = l.deferreddatafields;
							if (p == null) {
								if (l.columns.records.length > 0) {
									p = new Array();
									p.push(l.columns.records[0].displayfield)
								}
							}
							for ( var o = 0; o < p.length; o++) {
								var t = p[o];
								var q = l._getcolumnbydatafield(t);
								if (q) {
									var n = l._getcellvalue(q, m);
									if (q.cellsformat != "") {
										if (b.jqx.dataFormat) {
											if (b.jqx.dataFormat.isDate(n)) {
												n = b.jqx.dataFormat.formatdate(n, q.cellsformat, l.gridlocalization)
											} else {
												if (b.jqx.dataFormat.isNumber(n)) {
													n = b.jqx.dataFormat.formatnumber(n, q.cellsformat, l.gridlocalization)
												}
											}
										}
									}
									r += "<tr><td>" + n + "</td></tr>"
								}
							}
							r += "</table>";
							return r
						};
						var h = this.scrollfeedback ? this.scrollfeedback(m.bounddata) : i(m.bounddata);
						if (h != this._scrollelementcontent) {
							this._scrollelement[0].innerHTML = h;
							this._scrollelementcontent = h
						}
					}
					this._scrollelement.css("visibility", "visible");
					this._scrollelementoverlay.css("visibility", "visible");
					this._scrollelement.css("margin-top", -this._scrollelement.height() / 2);
					this._scrolltimer = setInterval(function() {
						if (!l.hScrollInstance.isScrolling() && !l.vScrollInstance.isScrolling()) {
							k();
							l._scrollelement.css("visibility", "hidden");
							l._scrollelementoverlay.css("visibility", "hidden");
							clearInterval(l._scrolltimer);
							if (m) {
								l.ensurerowvisible(m.visibleindex)
							}
						}
					}, 100);
					return
				}
				if (navigator && navigator.userAgent.indexOf("Chrome") == -1 && navigator.userAgent.indexOf("Safari") != -1) {
					this.updatedelay = 1
				}
				if (this.touchDevice != undefined && this.touchDevice == true) {
					this.updatedelay = 5
				}
				var g = this._browser == undefined ? this._isIE10() : this._browser;
				if (g) {
					this.updatedelay = 5
				}
				if ((g || b.jqx.browser.mozilla) && this.hScrollInstance.isScrolling()) {
					k();
					return
				}
				if (b.jqx.browser.mozilla && this.updatedelay == 0 && (this.vScrollInstance.isScrolling() || this.hScrollInstance.isScrolling())) {
					d = setTimeout(function() {
						k()
					}, 0.01);
					return
				}
				if (this.updatedelay == 0) {
					k()
				} else {
					var d = b.data(document.body, "Grid" + this.element.id);
					if (d != null) {
						clearTimeout(d)
					}
					if (this.vScrollInstance.isScrolling() || this.hScrollInstance.isScrolling()) {
						d = setTimeout(function() {
							k()
						}, this.updatedelay);
						b.data(document.body, "Grid" + this.element.id, d)
					} else {
						b.data(document.body, "Grid" + this.element.id, null);
						k()
					}
				}
			}
		},
		scrolling : function() {
			var e = this.vScrollInstance.isScrolling();
			var d = this.hScrollInstance.isScrolling();
			return {
				vertical : e,
				horizontal : d
			}
		},
		_renderhorizontalscroll : function() {
			var s = this.hScrollInstance;
			var t = s.value;
			var k = parseInt(t);
			if (this.table == null) {
				return
			}
			var p = this.table[0].rows.length;
			var o = this.columnsrow;
			var q = this.groupable && this.groups.length > 0 ? this.groups.length : 0;
			var l = this.columns.records.length - q;
			var f = this.columns.records;
			var n = this.dataview.rows.length == 0;
			if (this.rtl) {
				k = s.max - k
			}
			if (n) {
				for ( var v = 0; v < p; v++) {
					var r = this.table[0].rows[v];
					for ( var u = 0; u < q + l; u++) {
						var d = r.cells[u];
						if (d != undefined) {
							var g = f[u];
							if (g.pinned) {
								d.style.marginLeft = k + "px";
								if (v == 0) {
									var e = o[0].cells[u];
									e.style.marginLeft = k + "px"
								}
							}
						}
					}
				}
				this.table[0].style.marginLeft = -k + "px";
				o[0].style.marginLeft = -k + "px"
			} else {
				if (this._haspinned || this._haspinned == undefined) {
					for ( var v = 0; v < p; v++) {
						var r = this.table[0].rows[v];
						for ( var u = 0; u < q + l; u++) {
							var d = r.cells[u];
							if (d != undefined) {
								var g = f[u];
								if (g.pinned) {
									if (k == 0 && d.style.marginLeft == "") {
										continue
									}
									var h = null;
									var w = null;
									if (this.showfilterrow && this.filterrow) {
										if (this.filterrow[0].cells) {
											w = this.filterrow[0].cells[u]
										}
									}
									if (this.showaggregates) {
										if (this.statusbar[0].cells) {
											h = this.statusbar[0].cells[u]
										}
									}
									if (!this.rtl) {
										d.style.marginLeft = k + "px";
										if (v == 0) {
											var e = o[0].cells[u];
											e.style.marginLeft = k + "px";
											if (h) {
												h.style.marginLeft = k + "px"
											}
											if (w) {
												w.style.marginLeft = k + "px"
											}
										}
									} else {
										d.style.marginLeft = -parseInt(t) + "px";
										if (v == 0) {
											var e = o[0].cells[u];
											e.style.marginLeft = -parseInt(t) + "px";
											if (h) {
												h.style.marginLeft = -parseInt(t) + "px"
											}
											if (w) {
												w.style.marginLeft = -parseInt(t) + "px"
											}
										}
									}
								}
							}
						}
					}
					this.table[0].style.marginLeft = -k + "px";
					o[0].style.marginLeft = -k + "px"
				} else {
					if (this._haspinned == false) {
						this.table[0].style.marginLeft = -k + "px";
						o[0].style.marginLeft = -k + "px"
					}
				}
			}
			if (this.showaggregates) {
				if (this.statusbar[0].cells) {
					var m = 0;
					if (this.rtl) {
						if (this.vScrollBar.css("visibility") != "hidden") {
							m = 2 + parseInt(this.hScrollBar.css("left"))
						}
					}
					this.statusbar[0].style.marginLeft = -k + m + "px"
				}
			}
			if (this.showfilterrow && this.filterrow) {
				if (this.filterrow[0].cells) {
					this.filterrow[0].style.marginLeft = -k + "px"
				}
			}
		},
		_updaterowdetailsvisibility : function() {
			if (this.rowdetails) {
				for ( var d = 0; d < this._rowdetailselementscache.length; d++) {
					b(this._rowdetailselementscache[d]).css("display", "none")
				}
			}
		},
		_getvisualcolumnsindexes : function(e, m, i, l, d) {
			if (this.rowdetails || this.rtl) {
				return {
					start : 0,
					end : i + l
				}
			}
			var f = 0;
			var k = -1;
			var g = i + l;
			var n = false;
			if (this.autorowheight) {
				return {
					start : 0,
					end : l
				}
			}
			if (!d) {
				for ( var h = 0; h < i + l; h++) {
					var o = h;
					if (!n) {
						if (this.columns.records[h].pinned) {
							n = true
						}
					}
					if (!this.columns.records[h].hidden) {
						f += this.columns.records[h].width
					}
					if (f >= e && k == -1) {
						k = h
					}
					if (f > m + e) {
						g = h;
						break
					}
				}
			}
			g++;
			if (g > i + l) {
				g = i + l
			}
			if (k == -1 || n) {
				k = 0
			}
			return {
				start : k,
				end : g
			}
		},
		_getfirstvisualrow : function() {
			var e = this.vScrollInstance;
			var g = e.value;
			var f = parseInt(g);
			if (this._pagescache.length == 0) {
				this.dataview.updateview();
				this._loadrows()
			}
			if (this.vScrollBar[0].style.visibility != "visible") {
				f = 0
			}
			if (!this.pageable) {
				var d = this._findvisiblerow(f, this._pageviews);
				if (d == -1) {
					return null
				}
				if (d != this.dataview.pagenum) {
					this.dataview.pagenum = d;
					this.dataview.updateview();
					this._loadrows()
				} else {
					if (!this._pagescache[this.dataview.pagenum]) {
						this._loadrows()
					}
				}
			}
			var h = this._findvisiblerow(f, this._pagescache[this.dataview.pagenum]);
			var i = this._pagescache[this.dataview.pagenum];
			if (i && i[0]) {
				return i[h]
			}
		},
		_rendervisualrows : function() {
			if (!this.virtualsizeinfo) {
				return
			}
			var R = this.vScrollInstance;
			var o = this.hScrollInstance;
			var h = R.value;
			var z = o.value;
			var n = parseInt(h);
			var k = parseInt(z);
			var v = this._gettableheight();
			var E = this._hostwidth != undefined ? this._hostwidth : this.host.width();
			if (this.hScrollBar[0].style.visibility == "visible") {
				v += this.rowsheight
			}
			if (this.scrollmode == "deferred" && this._newmax != 0) {
				if (n > this._newmax) {
					n = this._newmax
				}
			}
			var A = this.groupable && this.groups.length > 0;
			this.visiblerows = new Array();
			this.hittestinfo = new Array();
			if (this.editcell && this.editrow == undefined) {
				this._hidecelleditor()
			}
			if (this.editrow != undefined) {
				this._hideeditors()
			}
			if (this.virtualmode && !this.pageable) {
				this._pagescache = new Array()
			}
			if (this._pagescache.length == 0) {
				this.dataview.updateview();
				this._loadrows()
			}
			if (this.vScrollBar[0].style.visibility != "visible") {
				n = 0
			}
			if (!this.pageable) {
				var G = this._findvisiblerow(n, this._pageviews);
				if (G == -1) {
					this._clearvisualrows();
					this._renderemptyrow();
					this._updaterowdetailsvisibility();
					return
				}
				if (G != this.dataview.pagenum) {
					this.dataview.pagenum = G;
					this.dataview.updateview();
					this._loadrows()
				} else {
					if (!this._pagescache[this.dataview.pagenum]) {
						this._loadrows()
					}
				}
			}
			var ac = this.groupable && this.groups.length > 0 ? this.groups.length : 0;
			var q = this.columns.records.length - ac;
			var V = this._findvisiblerow(n, this._pagescache[this.dataview.pagenum]);
			var H = this._pagescache[this.dataview.pagenum];
			var M = V;
			if (M < 0) {
				M = 0
			}
			var X = 0;
			var U = 0;
			var L = 0;
			var e = 0;
			var N = this.virtualsizeinfo.visiblerecords;
			var K = this.groupable ? this.groups.length : 0;
			var x = this.toTP("jqx-grid-cell");
			if (this.rtl) {
				x += " " + this.toTP("jqx-grid-cell-rtl")
			}
			if (this.autoheight && this.pageable) {
				if (!this.groupable) {
					N = this.dataview.pagesize
				}
			}
			if (A) {
				x = " " + this.toTP("jqx-grid-group-cell")
			}
			if (this.isTouchDevice()) {
				x += " " + this.toTP("jqx-touch")
			}
			if (this.autorowheight) {
				x += " jqx-grid-cell-wrap"
			}
			var J = this.rowsheight;
			var D = M;
			var ab = this._rendercell;
			var r = true;
			var p = this._getvisualcolumnsindexes(k, E, ac, q, A);
			var d = p.start;
			var T = p.end;
			if (this.autoheight && this.autorowheight) {
				if (this._pageviews[0]) {
					this._oldpageviewheight = this._pageviews[0].height
				}
			}
			if (M >= 0) {
				this._updaterowdetailsvisibility();
				this._startboundindex = H != null ? H[M].bounddata.boundindex : 0;
				this._startvisibleindex = H != null ? H[M].bounddata.visibleindex : 0;
				for ( var m = 0; m < N && U < N; m++) {
					var W = H != undefined ? H[M + m] : null;
					if (W == null) {
						M = -m;
						if (this._pagescache[this.dataview.pagenum + 1]) {
							H = this._pagescache[this.dataview.pagenum + 1];
							this.dataview.pagenum++
						} else {
							var s = this._pageviews.length;
							do {
								if (this.dataview.pagenum < this._pageviews.length - 1) {
									this.dataview.pagenum++;
									H = undefined;
									if (this._pageviews[this.dataview.pagenum].height > 0) {
										this.dataview.updateview();
										this._loadrows();
										H = this._pagescache[this.dataview.pagenum]
									}
								} else {
									H = undefined;
									break
								}
							} while (H == undefined && this.dataview.pagenum < s)
						}
						if (H != undefined) {
							W = H[M + m]
						}
					}
					if (W != null) {
						if (W.hidden) {
							continue
						}
						this._endboundindex = this._startboundindex + m;
						this._endvisibleindex = this._startvisibleindex + m;
						if (m == 0) {
							var l = Math.abs(n - W.top);
							this.table[0].style.top = -l + "px";
							e = -l
						}
						var j = this.table[0].rows[U];
						if (!j) {
							continue
						}
						if (parseInt(j.style.height) != W.height) {
							j.style.height = parseInt(W.height) + "px"
						}
						L += W.height;
						var Q = this.rowdetails && W.rowdetails;
						var u = !W.rowdetailshidden;
						if (Q && u) {
							j.style.height = parseInt(W.height - W.rowdetailsheight) + "px";
							N++
						}
						var F = this._isrowselected(r, W);
						for ( var O = d; O < T; O++) {
							var Z = O;
							this._rendervisualcell(ab, x, F, Q, u, A, K, j, W, Z, U)
						}
						if (W.group != undefined && this._rendergroup) {
							this._rendergroup(K, j, W, ac, q, U, E)
						}
						if (this.autorowheight && this.autoheight) {
							var J = this.rowsheight;
							for ( var O = d; O < T; O++) {
								if (this.editable && this.editcell && this.editcell.column == this.columns.records[O].datafield && this.editcell.row == W.boundindex) {
									continue
								}
								J = Math.max(J, 8 + b(j.cells[O].firstChild).height())
							}
							j.style.height = parseInt(J) + "px";
							this.heights[this._startboundindex + m] = J;
							if (Q && u) {
								J += W.rowdetailsheight
							}
							W.height = J
						}
						this.visiblerows[this.visiblerows.length] = W;
						this.hittestinfo[this.hittestinfo.length] = {
							row : W,
							visualrow : j,
							details : false
						};
						if (Q && u) {
							U++;
							var j = this.table[0].rows[U];
							this._renderrowdetails(x, j, W, ac, q, U);
							this.visiblerows[this.visiblerows.length] = W;
							this.hittestinfo[this.hittestinfo.length] = {
								row : W,
								visualrow : j,
								details : true
							}
						}
						if (L + e >= v) {
							break
						}
					} else {
						cansetheight = true;
						this._clearvisualrow(k, A, U, ac, q);
						if (L + X + e <= v) {
							X += J
						}
					}
					U++
				}
				this._horizontalvalue = k;
				if (X > 0) {
					if (this.vScrollBar[0].style.visibility == "visible") {
						var aa = parseInt(this.table.css("top"));
						var C = this._pageviews[this._pageviews.length - 1];
						var t = R.max;
						var B = C.top + C.height - v;
						if (this.hScrollBar.css("visibility") == "visible") {
							B += this.scrollbarsize + 20
						}
						if (t != B) {
							if (B >= 0) {
								if (this.scrollmode != "deferred") {
									R.max = B;
									R.setPosition(R.max)
								} else {
									if (this._newmax != B) {
										this._newmax = B;
										this._rendervisualrows()
									}
								}
							}
						}
					}
				}
			}
			if (this.autoheight && this.autorowheight) {
				this._pagescache = new Array();
				var P = 0;
				var g = 0;
				for ( var Y = 0; Y < this.visiblerows.length; Y++) {
					var w = this.visiblerows[Y];
					w.top = P;
					P += w.height;
					g += w.height;
					var Q = this.rowdetails && w.rowdetails;
					var u = !w.rowdetailshidden;
					var j = this.table[0].rows[Y];
					for ( var O = d; O < T; O++) {
						var S = this.columns.records[O];
						if (!S.hidden) {
							if (!S.cellsrenderer) {
								var I = j.cells[O];
								var f = (w.height - b(I.firstChild).height() - 8) / 2;
								if (f > 0) {
									f = parseInt(f) + 4;
									if (I.firstChild) {
										if (I.firstChild.className.indexOf("jqx-grid-groups-row") == -1) {
											if (S.columntype != "checkbox" && S.columntype != "button") {
												if (this.editable && this.editcell && this.editcell.column == S.datafield && this.editcell.row == w.boundindex) {
													continue
												}
												I.firstChild.style.marginTop = f + "px"
											}
										}
									}
								}
							}
						}
					}
				}
				if (this._pageviews[0]) {
					this._pageviews[0].height = g
				}
				this._arrange()
			}
			this._renderemptyrow()
		},
		_renderemptyrow : function() {
			if (this._loading) {
				return
			}
			if (this.dataview.records.length == 0 && this.showemptyrow) {
				var k = false;
				if (this.table && this.table.length > 0 && this.table[0].rows && this.table[0].rows.length > 0) {
					var j = this.table[0].rows[0];
					for ( var e = 0; e < j.cells.length; e++) {
						var d = b(j.cells[e]);
						if (d.css("display") != "none" && !k) {
							d[0].checkbox = null;
							d[0].button = null;
							k = true;
							d[0].innerHTML = "";
							var f = b("<span style='white-space: nowrap; float: left; margin-left: 50%; position: relative;'></span>");
							f.text(this.gridlocalization.emptydatastring);
							d.append(f);
							var h = 0;
							if (!this.oldhscroll) {
								h = parseInt(this.table[0].style.marginLeft);
								if (this.rtl) {
									d.css("z-index", 999);
									d.css("overflow", "visible")
								}
							}
							f.css("left", -h - (f.width() / 2));
							f.css("top", this._gettableheight() / 2 - f.height() / 2);
							if (b.jqx.browser.msie && b.jqx.browser.version < 8) {
								f.css("margin-left", "0px");
								f.css("left", this.host.width() / 2 - f.width() / 2)
							}
							var g = Math.abs(parseInt(this.table[0].style.top));
							if (isNaN(g)) {
								g = 0
							}
							b(j).height(this._gettableheight() + g);
							d.css("margin-left", "0px");
							d.width(this.host.width())
						}
						d.addClass(this.toThemeProperty("jqx-grid-empty-cell"))
					}
				}
			}
		},
		_clearvisualrows : function() {
			var e = this.virtualsizeinfo.visiblerecords;
			var f = this.hScrollInstance;
			var d = f.value;
			var g = parseInt(d);
			var i = this.groupable && this.groups.length > 0;
			for ( var h = 0; h < e; h++) {
				this._clearvisualrow(g, i, h, 0, this.columns.records.length)
			}
		},
		_isrowselected : function(f, e) {
			var d = false;
			if (f && e.bounddata != null) {
				if (this.selectionmode != "singlerow") {
					if (this.selectedrowindexes.indexOf(e.bounddata.boundindex) != -1) {
						d = true
					}
				} else {
					if (e.bounddata.boundindex == this.selectedrowindex) {
						d = true
					}
				}
			}
			return d
		},
		_rendervisualcell : function(w, i, n, k, q, u, j, o, d, h, p) {
			var f = null;
			var g = this.columns.records[h];
			if (g.hidden) {
				var e = o.cells[h];
				e.innerHTML = "";
				return
			}
			cellvalue = this._getcellvalue(g, d);
			var e = o.cells[h];
			var t = i;
			if (g.cellclassname != "" && g.cellclassname) {
				t += " " + g.cellclassname
			}
			if (this.selectionmode.indexOf("cell") != -1) {
				if (this.selectedcells[d.boundindex + "_" + g.datafield]) {
					n = true
				} else {
					n = false
				}
			}
			var m = this.showsortcolumnbackground && this.sortcolumn && g.displayfield == this.sortcolumn;
			if (m) {
				t += " " + this.toTP("jqx-grid-cell-sort")
			}
			if (g.filter && this.showfiltercolumnbackground) {
				t += " " + this.toTP("jqx-grid-cell-filter")
			}
			if (g.pinned && this.showpinnedcolumnbackground) {
				if (u) {
					t += " " + this.toTP("jqx-grid-cell-pinned")
				} else {
					t += " " + this.toTP("jqx-grid-cell-pinned")
				}
			}
			if (this.altrows && d.group == undefined) {
				var v = d.visibleindex;
				if (v >= this.altstart) {
					if ((this.altstart + v) % (1 + this.altstep) == 0) {
						if (!m) {
							t += " " + this.toTP("jqx-grid-cell-alt")
						} else {
							t += " " + this.toTP("jqx-grid-cell-sort-alt")
						}
						if (g.filter && this.showfiltercolumnbackground) {
							t += " " + this.toTP("jqx-grid-cell-filter-alt")
						}
						if (g.pinned && this.showpinnedcolumnbackground) {
							t += " " + this.toTP("jqx-grid-cell-pinned-alt")
						}
					}
				}
			}
			if (h <= j) {
				if (u || this.rowdetails) {
					var r = b(e);
					var l = this.columns.records[h].width;
					if (parseInt(e.style.width) != l) {
						r.width(l)
					}
				}
			}
			var s = true;
			if (this.rowdetails && k) {
				if (q && !u) {
					t += " " + this.toTP("jqx-grid-details-cell")
				} else {
					if (u) {
						t += " " + this.toTP("jqx-grid-group-details-cell")
					}
				}
				if (this.showrowdetailscolumn) {
					if (d.group == undefined && h == j) {
						if (q) {
							t += " " + this.toTP("jqx-grid-group-expand")
						} else {
							t += " " + this.toTP("jqx-grid-group-collapse")
						}
						s = false
					}
				}
			}
			if (n && s) {
				t += " " + this.toTP("jqx-grid-cell-selected");
				t += " " + this.toTP("jqx-fill-state-pressed")
			}
			if (e.className != t) {
				e.className = t
			}
			if (d.group != undefined) {
				cellvalue = "";
				e.title = "";
				e.innerHTML = "";
				return
			}
			w(this, g, d, cellvalue, e)
		},
		_rendercell : function(k, f, n, m, e) {
			var g = m + "_" + f.visibleindex;
			if (f.columntype == "number" || f.cellsrenderer != null) {
				var g = n.uniqueid + "_" + f.visibleindex
			}
			if (k.editcell && k.editrow == undefined) {
				if (k.editcell.row == n.boundindex && k.editcell.column == f.datafield) {
					k.editcell.element = e;
					if (k.editcell.editing) {
						if (k._showcelleditor) {
							if (!k.hScrollInstance.isScrolling() && !k.vScrollInstance.isScrolling()) {
								k._showcelleditor(k.editcell.row, f, k.editcell.element, k.editcell.init)
							} else {
								k._showcelleditor(k.editcell.row, f, k.editcell.element, k.editcell.init, false)
							}
							return
						}
					}
				}
			} else {
				if (k.editrow != undefined) {
					if (k.editrow == n.boundindex) {
						k.editcells[f.datafield].element = e;
						if (k.editcells[f.datafield].editing) {
							if (k._showcelleditor) {
								k._showcelleditor(k.editcells[f.datafield].row, f, e, k.editcells[f.datafield].init);
								return
							}
						}
					}
				}
			}
			var j = k._cellscache[g];
			if (j) {
				if (f.columntype == "checkbox") {
					if (k.host.jqxCheckBox) {
						if (m === "") {
							m = null
						}
						var i = e.innerHTML.toString().length == 0;
						if (e.checkbox && !k.groupable && !i) {
							e.checkboxrow = n.boundindex;
							if (m == "") {
								m = false
							}
							if (m == "1") {
								m = true
							}
							if (m == "0") {
								m = false
							}
							if (m == 1) {
								m = true
							}
							if (m == 0) {
								m = false
							}
							if (m == "true") {
								m = true
							}
							if (m == "false") {
								m = false
							}
							if (m == null && !f.threestatecheckbox) {
								m = false
							}
							e.checkbox.jqxCheckBox("_setState", m)
						} else {
							k._rendercheckboxcell(k, e, f, n, m)
						}
						if (f.cellsrenderer != null) {
							var h = f.cellsrenderer(n.boundindex, f.datafield, m, l, f.getcolumnproperties());
							if (h != undefined) {
								e.innerHTML = h
							}
						}
						return
					}
				} else {
					if (f.columntype == "button") {
						if (k.host.jqxButton) {
							if (m == "") {
								m = false
							}
							if (f.cellsrenderer != null) {
								m = f.cellsrenderer(n.boundindex, f.datafield, m, l, f.getcolumnproperties())
							}
							if (e.innerHTML == "") {
								e.buttonrow = n.boundindex;
								e.button = null;
								k._renderbuttoncell(k, e, f, n, m)
							}
							if (e.button && !k.groupable) {
								e.buttonrow = n.boundindex;
								e.button.val(m)
							} else {
								k._renderbuttoncell(k, e, f, n, m)
							}
							return
						}
					}
				}
				var d = j.element;
				if (e.innerHTML != d) {
					e.innerHTML = d;
					if (k.enabletooltips) {
						e.title = j.title
					}
				}
				return
			}
			if (k.enabletooltips) {
				if (f.cellsformat != "") {
					if (b.jqx.dataFormat) {
						if (b.jqx.dataFormat.isNumber(m)) {
							m = b.jqx.dataFormat.formatnumber(m, f.cellsformat, k.gridlocalization)
						} else {
							if (b.jqx.dataFormat.isDate(m)) {
								m = b.jqx.dataFormat.formatdate(m, f.cellsformat, k.gridlocalization)
							}
						}
					}
				}
				e.title = m
			}
			if (f.columntype == "checkbox") {
				k._rendercheckboxcell(k, e, f, n, m);
				k._cellscache[g] = {
					element : "",
					title : m
				};
				return
			} else {
				if (f.columntype == "button") {
					if (f.cellsrenderer != null) {
						m = f.cellsrenderer(n.boundindex, f.datafield, m, l, f.getcolumnproperties())
					}
					k._renderbuttoncell(k, e, f, n, m);
					k._cellscache[g] = {
						element : "",
						title : m
					};
					return
				} else {
					if (f.columntype == "number") {
						m = n.visibleindex
					}
				}
			}
			var l = k._defaultcellsrenderer(m, f);
			var d = null;
			if (f.cellsrenderer != null) {
				d = f.cellsrenderer(n.boundindex, f.datafield, m, l, f.getcolumnproperties())
			} else {
				d = l
			}
			if (d == null) {
				d = l
			}
			if (k.WinJS) {
				WinJS.Utilities.setInnerHTMLUnsafe(e, d)
			} else {
				e.innerHTML = d
			}
			k._cellscache[g] = {
				element : e.innerHTML,
				title : m
			};
			return true
		},
		_isIE10 : function() {
			if (this._browser == undefined) {
				var e = b.jqx.utilities.getBrowser();
				if (e.browser == "msie" && parseInt(e.version) > 9) {
					this._browser = true
				} else {
					this._browser = false;
					if (e.browser == "msie") {
						var d = "Browser CodeName: " + navigator.appCodeName + "";
						d += "Browser Name: " + navigator.appName + "";
						d += "Browser Version: " + navigator.appVersion + "";
						d += "Platform: " + navigator.platform + "";
						d += "User-agent header: " + navigator.userAgent + "";
						if (d.indexOf("Zune 4.7") != -1) {
							this._browser = true
						}
					}
				}
			}
			return this._browser
		},
		_rendercheckboxcell : function(f, d, e, j, g) {
			if (f.host.jqxCheckBox) {
				var i = b(d);
				if (g === "") {
					if (e.threestatecheckbox) {
						g = null
					} else {
						g = false
					}
				}
				if (g == "1") {
					g = true
				}
				if (g == "0") {
					g = false
				}
				if (g == 1) {
					g = true
				}
				if (g == 0) {
					g = false
				}
				if (g == "true") {
					g = true
				}
				if (g == "false") {
					g = false
				}
				if (i.find(".jqx-checkbox").length == 0) {
					d.innerHTML = '<div tabIndex=0 style="opacity: 0.99; position: absolute; top: 50%; left: 50%; margin-top: -7px; margin-left: -10px;"></div>';
					b(d.firstChild).jqxCheckBox({
						hasInput : false,
						hasThreeStates : e.threestatecheckbox,
						enableContainerClick : false,
						animationShowDelay : 0,
						animationHideDelay : 0,
						locked : true,
						theme : f.theme,
						checked : g
					});
					if (this.editable && e.editable) {
						b(d.firstChild).jqxCheckBox({
							locked : false
						})
					}
					d.checkbox = b(d.firstChild);
					d.checkboxrow = j.boundindex;
					var h = b.data(d.firstChild, "jqxCheckBox").instance;
					h.updated = function(n, m, p) {
						if (e.editable) {
							var o = f.table[0].rows.length;
							var r = f._getcolumnindex(e.datafield);
							if (f.editrow == undefined) {
								if (e.cellbeginedit) {
									var q = e.cellbeginedit(j.boundindex, e.datafield, e.columntype, !m);
									if (q == false) {
										f.setcellvalue(d.checkboxrow, e.datafield, !m, true);
										return
									}
								}
								for ( var l = 0; l < o; l++) {
									var k = f.table[0].rows[l].cells[r].firstChild;
									b(k).jqxCheckBox("destroy")
								}
								if (f.editcell && f.editcell.validated == false) {
									f.setcellvalue(d.checkboxrow, e.datafield, !m, true)
								} else {
									f._raiseEvent(17, {
										rowindex : d.checkboxrow,
										datafield : e.datafield,
										value : p,
										columntype : e.columntype
									});
									f.setcellvalue(d.checkboxrow, e.datafield, m, true);
									f._raiseEvent(18, {
										rowindex : d.checkboxrow,
										datafield : e.datafield,
										oldvalue : p,
										value : m,
										columntype : e.columntype
									})
								}
							}
						}
					}
				} else {
					d.checkboxrow = j.boundindex;
					b(d.firstChild).jqxCheckBox("_setState", g)
				}
			}
		},
		_renderbuttoncell : function(h, e, g, k, i) {
			if (h.host.jqxButton) {
				var j = b(e);
				if (i == "") {
					i = false
				}
				if (j.find(".jqx-button").length == 0) {
					e.innerHTML = '<input type="button" style="opacity: 0.99; position: absolute; top: 0%; left: 0%; padding: 0px; margin-top: 2px; margin-left: 2px;"/>';
					b(e.firstChild).val(i);
					b(e.firstChild).attr("hideFocus", "true");
					b(e.firstChild).jqxButton({
						theme : h.theme,
						height : h.rowsheight - 4,
						width : g.width - 4
					});
					e.button = b(e.firstChild);
					e.buttonrow = k.boundindex;
					var d = this.isTouchDevice();
					if (d) {
						var f = b.jqx.mobile.getTouchEventName("touchend");
						b(e.firstChild).on(f, function(l) {
							if (g.buttonclick) {
								g.buttonclick(e.buttonrow, l)
							}
						})
					} else {
						b(e.firstChild).on("click", function(l) {
							if (g.buttonclick) {
								g.buttonclick(e.buttonrow, l)
							}
						})
					}
				} else {
					e.buttonrow = k.boundindex;
					b(e.firstChild).val(i)
				}
			}
		},
		_clearvisualrow : function(g, f, o, i, n) {
			var m = this.toTP("jqx-grid-cell");
			if (f) {
				m = " " + this.toTP("jqx-grid-group-cell")
			}
			var p = this.table[0].rows;
			for ( var k = 0; k < i + n; k++) {
				if (p[o]) {
					var e = p[o].cells[k];
					if (e.className != m) {
						e.className = m
					}
					var d = this.columns.records[k];
					if (this._horizontalvalue != g && !d.pinned) {
						if (this.oldhscroll == true) {
							var h = -g;
							e.style.marginLeft = -g + "px"
						}
					}
					var l = d.width;
					if (l < d.minwidth) {
						l = d.minwidth
					}
					if (l > d.maxwidth) {
						l = d.maxwidth
					}
					if (parseInt(e.style.width) != l) {
						b(e).width(l)
					}
					if (e.title != "") {
						e.title = ""
					}
					if (e.innerHTML != "") {
						e.innerHTML = ""
					}
				}
			}
			if (p[o]) {
				if (parseInt(p[o].style.height) != this.rowsheight) {
					b(p[o]).height(this.rowsheight)
				}
			}
		},
		_findgroupstate : function(e) {
			var d = this._findgroup(e);
			if (d == null) {
				return false
			}
			return d.expanded
		},
		_findgroup : function(e) {
			var d = null;
			if (this.expandedgroups[e]) {
				return this.expandedgroups[e]
			}
			return d
		},
		_clearcaches : function() {
			this._columnsbydatafield = new Array();
			this._pagescache = new Array();
			this._pageviews = new Array();
			this._cellscache = new Array();
			this.heights = new Array();
			this.hiddens = new Array();
			this.hiddenboundrows = new Array();
			this.heightboundrows = new Array();
			this.detailboundrows = new Array();
			this.details = new Array();
			this.expandedgroups = new Array();
			this._rowdetailscache = new Array();
			this._rowdetailselementscache = new Array();
			if (b.jqx.dataFormat) {
				b.jqx.dataFormat.cleardatescache()
			}
			this.tableheight = null
		},
		_getColumnText : function(d) {
			if (this._columnsbydatafield == undefined) {
				this._columnsbydatafield = new Array()
			}
			if (this._columnsbydatafield[d]) {
				return this._columnsbydatafield[d]
			}
			var f = d;
			var e = null;
			b.each(this.columns.records, function() {
				if (this.datafield == d) {
					f = this.text;
					e = this;
					return false
				}
			});
			this._columnsbydatafield[d] = {
				label : f,
				column : e
			};
			return this._columnsbydatafield[d]
		},
		_getcolumnbydatafield : function(d) {
			if (this.__columnsbydatafield == undefined) {
				this.__columnsbydatafield = new Array()
			}
			if (this.__columnsbydatafield[d]) {
				return this.__columnsbydatafield[d]
			}
			var f = d;
			var e = null;
			b.each(this.columns.records, function() {
				if (this.datafield == d || this.displayfield == d) {
					f = this.text;
					e = this;
					return false
				}
			});
			this.__columnsbydatafield[d] = e;
			return this.__columnsbydatafield[d]
		},
		isscrollingvertically : function() {
			var d = (this.vScrollBar.jqxScrollBar("isScrolling"));
			return d
		},
		_renderrowdetails : function(n, t, d, s, l, v) {
			var x = b(t);
			var g = 0;
			var p = this.rowdetails && this.showrowdetailscolumn ? (1 + this.groups.length) * this.groupindentwidth : (this.groups.length) * this.groupindentwidth;
			if (this.groupable && this.groups.length > 0) {
				for ( var o = 0; o <= l; o++) {
					var e = b(t.cells[o]);
					e[0].innerHTML = "";
					e[0].className = "jqx-grid-details-cell"
				}
			}
			var e = b(t.cells[g]);
			e.css("width", "100%");
			x.height(d.rowdetailsheight);
			e[0].className = n;
			var m = d.bounddata.boundindex;
			var j = m + "_";
			if (this._rowdetailscache[j]) {
				var q = this._rowdetailscache[j];
				var w = q.html;
				if (this.initrowdetails) {
					if (this._rowdetailscache[j].element) {
						var f = this._rowdetailscache[j].element;
						var i = e.offset();
						var u = this.gridcontent.offset();
						var r = parseInt(i.top) - parseInt(u.top);
						var k = parseInt(i.left) - parseInt(u.left);
						b(f).css("top", r);
						b(f).css("left", k);
						b(f).css("display", "block")
					}
				} else {
					e[0].innerHTML = w
				}
				return
			}
			e[0].innerHTML = "";
			if (!this.enablerowdetailsindent) {
				p = 0
			}
			var h = '<div style="overflow: hidden; width: 100%; height: 100%; margin-left: ' + p + 'px;">' + d.rowdetails + "</div>";
			this._rowdetailscache[j] = {
				id : t.id,
				html : h
			};
			if (this.initrowdetails) {
				var f = b(h)[0];
				b(this.gridcontent).prepend(b(f));
				b(f).css("position", "absolute");
				b(f).width(this.host.width() - p);
				b(f).height(e.height());
				var i = e.offset();
				b(f).css("z-index", 2000);
				if (this.isTouchDevice()) {
					b(f).css("z-index", 99999)
				}
				var i = e.offset();
				var u = this.gridcontent.offset();
				var r = parseInt(i.top) - parseInt(u.top);
				var k = parseInt(i.left) - parseInt(u.left);
				b(f).css("top", r);
				b(f).css("left", k);
				this.content[0].scrollTop = 0;
				this.content[0].scrollLeft = 0;
				this.initrowdetails(m, f, this.element, this.getrowdata(m));
				this._rowdetailscache[j].element = f;
				this._rowdetailselementscache[m] = f
			} else {
				e[0].innerHTML = h
			}
		},
		_defaultcellsrenderer : function(f, d) {
			if (d.cellsformat != "") {
				if (!this.enabletooltips) {
					if (b.jqx.dataFormat) {
						if (b.jqx.dataFormat.isDate(f)) {
							f = b.jqx.dataFormat.formatdate(f, d.cellsformat, this.gridlocalization)
						} else {
							if (b.jqx.dataFormat.isNumber(f)) {
								f = b.jqx.dataFormat.formatnumber(f, d.cellsformat, this.gridlocalization)
							}
						}
					}
				}
			}
			var e = "4px";
			if (this.rowsheight != 25) {
				e = (this.rowsheight / 2 - this._cellheight / 2) + "px"
			}
			if (this.enableellipsis) {
				if (d.cellsalign == "center") {
					e = "5px";
					return '<div style="text-overflow: ellipsis; overflow: hidden; padding-bottom: 2px; text-align: center; margin-top: ' + e + ';">' + f + "</div>"
				}
				if (d.cellsalign == "left") {
					return '<div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: ' + e + ';">' + f + "</div>"
				}
				if (d.cellsalign == "right") {
					return '<div style="overflow: hidden;  text-overflow: ellipsis; padding-bottom: 2px; text-align: right; margin-right: 2px; margin-left: 4px; margin-top: ' + e + ';">' + f + "</div>"
				}
			}
			if (d.cellsalign == "center") {
				e = "5px";
				return '<div style="text-align: center; margin-top: ' + e + ';">' + f + "</div>"
			}
			return '<span style="margin-left: 4px; margin-right: 2px; margin-top: ' + e + "; float: " + d.cellsalign + ';">' + f + "</span>"
		},
		_getcellvalue : function(d, f) {
			var e = null;
			e = f.bounddata[d.datafield];
			if (d.displayfield != null) {
				e = f.bounddata[d.displayfield]
			}
			if (e == null) {
				e = ""
			}
			return e
		},
		getcell : function(h, d) {
			if (h == null || d == null) {
				return null
			}
			var e = parseInt(h);
			var g = h;
			var f = "";
			if (!isNaN(e)) {
				g = this.getrowdata(e)
			}
			if (g != null) {
				f = g[d]
			}
			return this._getcellresult(f, h, d)
		},
		getrenderedcell : function(h, d) {
			if (h == null || d == null) {
				return null
			}
			var e = parseInt(h);
			var g = h;
			var f = "";
			if (!isNaN(e)) {
				g = this.getrenderedrowdata(e)
			}
			if (g != null) {
				f = g[d]
			}
			return this._getcellresult(f, h, d)
		},
		_getcellresult : function(k, n, e) {
			var f = this.getcolumn(e);
			if (f == null || f == undefined) {
				return null
			}
			var i = f.getcolumnproperties();
			var g = i.hidden;
			var d = i.width;
			var m = i.pinned;
			var h = i.cellsalign;
			var j = i.cellsformat;
			var l = this.getrowheight(n);
			if (l == false) {
				return null
			}
			return {
				value : k,
				row : n,
				column : e,
				datafield : e,
				width : d,
				height : l,
				hidden : g,
				pinned : m,
				align : h,
				format : j
			}
		},
		setcellvalue : function(o, u, y, i, s) {
			if (o == null || u == null) {
				return false
			}
			var g = parseInt(o);
			var l = g;
			var j = o;
			if (!isNaN(g)) {
				j = this.getrowdata(g)
			}
			var v = false;
			if (this.filterable && this._initfilterpanel && this.dataview.filters.length) {
				v = true
			}
			if (this.virtualmode) {
				this._pagescache = new Array()
			}
			var q = "";
			if (j != null && j[u] != y) {
				var f = this._getcolumnbydatafield(u);
				var h = "string";
				var C = this.source.datafields || ((this.source._source) ? this.source._source.datafields : null);
				if (C) {
					var w = "";
					b.each(C, function() {
						if (this.name == f.displayfield) {
							if (this.type) {
								w = this.type
							}
							return false
						}
					});
					if (w) {
						h = w
					}
				}
				q = j[u];
				if (y == null || y.label == null) {
					if (b.jqx.dataFormat.isNumber(q) || h == "number" || h == "float" || h == "int" || h == "decimal" && h != "date") {
						y = new Number(y);
						y = parseFloat(y);
						if (isNaN(y)) {
							y = 0
						}
					} else {
						if (b.jqx.dataFormat.isDate(q) || h == "date") {
							if (y != "") {
								var B = y;
								B = new Date(B);
								if (B != "Invalid Date" && B != null) {
									y = B
								} else {
									if (B == "Invalid Date") {
										B = new Date();
										y = B
									}
								}
							}
						}
					}
				}
				j[u] = y;
				var E = this.getrenderedrowdata(g, true);
				E[u] = y;
				if (y != null && y.label != null) {
					var f = this._getcolumnbydatafield(u);
					j[f.displayfield] = y.label;
					E[f.displayfield] = y.label;
					j[u] = y.value;
					E[u] = y.value
				}
				if (v) {
					if (j.dataindex != undefined) {
						l = j.dataindex;
						this.dataview.cachedrecords[j.dataindex][u] = y
					}
				}
			} else {
				if (!this._updating && i != false) {
					this._renderrows(this.virtualsizeinfo)
				}
				return false
			}
			if (this.source && this.source._knockoutdatasource && !this._updateFromAdapter && this.autokoupdates) {
				if (this.source._source._localdata) {
					var x = this.source._source._localdata()[g];
					this.source.suspendKO = true;
					var n = x;
					if (n[u] && n[u].subscribe) {
						if (y != null && y.label != null) {
							n[f.displayfield](y.label);
							n[u](y.value)
						} else {
							n[u](y)
						}
					} else {
						if (y != null && y.label != null) {
							n[u] = y.value;
							n[f.displayfield] = y.label
						} else {
							n[u] = y
						}
						this.source._source._localdata.replace(x, b.extend({}, n))
					}
					this.source.suspendKO = false
				}
			}
			if (this.sortcolumn && this.dataview.sortby) {
				var r = this.getsortinformation();
				this.dataview.clearsortdata();
				this.dataview.sortby(r.sortcolumn, r.sortdirection.ascending)
			}
			this._cellscache = new Array();
			if (this.source.updaterow && (s == undefined || s == true)) {
				var p = false;
				var D = this;
				var t = function(F) {
					if (false == F) {
						D.setcellvalue(o, u, q, true, false)
					}
				};
				try {
					var m = this.getrowid(l);
					p = this.source.updaterow(m, j, t);
					if (p == undefined) {
						p = true
					}
				} catch (z) {
					p = false;
					D.setcellvalue(o, u, q, true, false);
					return
				}
			}
			var k = this.vScrollInstance.value;
			if (this._updating && i != true) {
				i = false
			}
			if (i == true || i == undefined) {
				var D = this;
				var e = function() {
					if (D.pageable && D.updatepagerdetails) {
						D.updatepagerdetails();
						if (D.autoheight) {
							D._updatepageviews()
						}
					}
				};
				var A = this.groupable && this.groups.length > 0;
				if (v && !A) {
					if (this.autoheight) {
						this.prerenderrequired = true
					}
					this.dataview.refresh();
					this.rendergridcontent(true, false);
					e();
					this._renderrows(this.virtualsizeinfo)
				} else {
					if (this.sortcolumn && !A) {
						if (this.autoheight) {
							this.prerenderrequired = true
						}
						this.dataview.reloaddata();
						this.rendergridcontent(true, false);
						e();
						this._renderrows(this.virtualsizeinfo)
					} else {
						if (this.groupable && this.groups.length > 0) {
							if (this.autoheight) {
								this.prerenderrequired = true
							}
							if (this.pageable) {
								if (this.groups.indexOf(u) != -1) {
									this.dataview.refresh();
									this.render(true, true, false, false)
								} else {
									this._pagescache = new Array();
									this._cellscache = new Array();
									this.dataview.updateview();
									this._renderrows(this.virtualsizeinfo)
								}
							} else {
								this._pagescache = new Array();
								this._cellscache = new Array();
								this.dataview.updateview();
								this._renderrows(this.virtualsizeinfo)
							}
						} else {
							this.dataview.updateview();
							this._renderrows(this.virtualsizeinfo)
						}
					}
				}
			}
			this.vScrollInstance.setPosition(k);
			if (this.showaggregates && this._updatecolumnsaggregates) {
				this._updatecolumnsaggregates()
			}
			if (this.showfilterrow && this.filterable && this.filterrow) {
				var d = this.getcolumn(u).filtertype;
				if (d == "list" || d == "checkedlist") {
					this._updatelistfilters(true)
				}
			}
			this._raiseEvent(19, {
				rowindex : o,
				datafield : u,
				newvalue : y,
				oldvalue : q
			});
			return true
		},
		getcellvalue : function(h, d) {
			if (h == null || d == null) {
				return null
			}
			var e = parseInt(h);
			var g = h;
			if (!isNaN(e)) {
				g = this.getrowdata(e)
			}
			if (g != null) {
				var f = g[d];
				return f
			}
			return null
		},
		getrows : function() {
			var f = this.dataview.records.length;
			if (this.dataview.sortdata) {
				var g = new Array();
				for ( var d = 0; d < f; d++) {
					var e = {};
					e = b.extend({}, this.dataview.sortdata[d].value);
					g[d] = e
				}
				return g
			} else {
				return this.dataview.records
			}
		},
		getrowdata : function(d) {
			if (d == undefined) {
				d = 0
			}
			if (this.virtualmode) {
				var e = this.dataview.records[d];
				return e
			} else {
				if (d >= 0 && d < this.dataview.bounditems.length) {
					var e = this.dataview.records[d];
					return e
				}
			}
			return null
		},
		getrenderedrowdata : function(d, f) {
			if (d == undefined) {
				d = 0
			}
			if (this.virtualmode) {
				var g = this.getrowvisibleindex(d);
				var e = this.dataview.loadedrecords[g];
				return e
			}
			if (d >= 0 && d < this.dataview.bounditems.length) {
				if (this.groupable && this.groups.length > 0) {
					var g = this.getrowvisibleindex(d);
					var e = this.dataview.loadedrecords[g]
				} else {
					var e = this.dataview.loadedrecords[d];
					if (this.pageable && (f == undefined || f == false)) {
						var e = this.dataview.loadedrecords[this.dataview.pagesize * this.dataview.pagenum + d]
					}
				}
				return e
			}
			return null
		},
		getloadedrows : function() {
			return this.dataview.loadedrecords
		},
		getvisiblerowdata : function(e) {
			var d = this.getvisiblerows();
			if (d) {
				return d[e]
			}
			return null
		},
		getrowboundindex : function(d) {
			var e = this.getvisiblerowdata();
			if (e) {
				return e.boundindex
			}
			return -1
		},
		getvisiblerows : function() {
			if (this.virtualmode) {
				return this.dataview.loadedrecords
			}
			if (this.pageable) {
				var f = [];
				for ( var e = 0; e < this.dataview.pagesize; e++) {
					var d = this.dataview.loadedrecords[e + (this.dataview.pagesize * this.dataview.pagenum)];
					if (d == undefined) {
						break
					}
					f.push(d)
				}
				return f
			} else {
				if (this._startboundindex != undefined && this._endboundindex != undefined) {
					var f = [];
					for ( var e = this._startvisibleindex; e <= this._endvisibleindex; e++) {
						var d = this.dataview.loadedrecords[e];
						if (d == undefined) {
							break
						}
						f.push(d)
					}
					return f
				}
			}
			return this.dataview.loadedrecords
		},
		getrowid : function(d) {
			if (d == undefined) {
				d = 0
			}
			if (this.virtualmode) {
				var g = this.getrowvisibleindex(d);
				var f = this.dataview.loadedrecords[g];
				if (f) {
					return f.uid
				}
			} else {
				var f = null;
				var e = this.dataview.filters.length > 0;
				if (d >= 0 && d < this.dataview.bounditems.length && !e) {
					if (this.groupable && this.groups.length > 0) {
						var g = this.getrowvisibleindex(d);
						var f = this.dataview.loadedrecords[g]
					} else {
						var g = this.getrowvisibleindex(d);
						var f = this.dataview.loadedrecords[g]
					}
					if (f) {
						return f.uid
					}
				}
				if (this.dataview.filters.length > 0) {
					if (this.groupable && this.groups.length > 0) {
						var g = this.getrowvisibleindex(d);
						var f = this.dataview.cachedrecords[g]
					} else {
						var g = this.getrowvisibleindex(d);
						var f = this.dataview.loadedrecords[g]
					}
					if (f) {
						if (f.uid != null) {
							return f.uid
						}
					}
					return null
				}
			}
			return null
		},
		_updateGridData : function() {
			var d = false;
			if (this.filterable && this._initfilterpanel && this.dataview.filters.length) {
				d = true
			}
			if (d) {
				this.dataview.refresh();
				this.render()
			} else {
				if (this.sortcolumn || (this.groupable && this.groups.length > 0)) {
					this.dataview.reloaddata();
					this.render()
				} else {
					this._cellscache = new Array();
					this._pagescache = new Array();
					this._renderrows(this.virtualsizeinfo)
				}
			}
			if (this.showfilterrow && this.filterable && this.filterrow) {
				this._updatelistfilters()
			}
		},
		updaterow : function(i, k, g) {
			if (i != undefined && k != undefined) {
				var h = this;
				var j = false;
				h._datachanged = true;
				var e = function(o, n, s) {
					var q = false;
					if (!b.isArray(n)) {
						q = o.dataview.updaterow(n, s)
					} else {
						b.each(n, function(t, u) {
							q = o.dataview.updaterow(this, s[t], false)
						});
						o.dataview.refresh()
					}
					var r = o.vScrollInstance.value;
					if (g == undefined || g == true) {
						if (o._updating == undefined || o._updating == false) {
							o._updateGridData()
						}
					}
					if (o.showaggregates && o._updatecolumnsaggregates) {
						o._updatecolumnsaggregates()
					}
					if (o.source && o.source._knockoutdatasource && !o._updateFromAdapter && o.autokoupdates) {
						if (o.source._source._localdata) {
							var m = o.dataview.recordsbyid["id" + n];
							var p = o.dataview.records.indexOf(m);
							var l = o.source._source._localdata()[p];
							o.source.suspendKO = true;
							o.source._source._localdata.replace(l, b.extend({}, m));
							o.source.suspendKO = false
						}
					}
					o.vScrollInstance.setPosition(r);
					return q
				};
				if (this.source.updaterow) {
					var d = function(l) {
						if (l == true || l == undefined) {
							e(h, i, k)
						}
					};
					try {
						j = this.source.updaterow(i, k, d);
						if (j == undefined) {
							j = true
						}
					} catch (f) {
						j = false
					}
				} else {
					j = e(h, i, k)
				}
				return j
			}
			return false
		},
		deleterow : function(h) {
			if (h != undefined) {
				this._datachanged = true;
				var i = false;
				var g = this;
				var e = function(k, j) {
					var l = false;
					var m = k.vScrollInstance.value;
					if (!b.isArray(j)) {
						var l = k.dataview.deleterow(j)
					} else {
						b.each(j, function() {
							l = k.dataview.deleterow(this, false)
						});
						k.dataview.refresh()
					}
					if (k._updating == undefined || k._updating == false) {
						k._render(true, true, false, false);
						if (k.vScrollBar.css("visibility") != "visible") {
							k._arrange();
							k._updatecolumnwidths();
							k._updatecellwidths();
							k._renderrows(k.virtualsizeinfo)
						}
					}
					if (k.source && k.source._knockoutdatasource && !k._updateFromAdapter && k.autokoupdates) {
						if (k.source._source._localdata) {
							k.source.suspendKO = true;
							k.source._source._localdata.pop(rowdata);
							k.source.suspendKO = false
						}
					}
					k.vScrollInstance.setPosition(m);
					return l
				};
				if (this.source.deleterow) {
					var d = function(j) {
						if (j == true || j == undefined) {
							e(g, h)
						}
					};
					try {
						this.source.deleterow(h, d);
						if (i == undefined) {
							i = true
						}
					} catch (f) {
						i = false
					}
				} else {
					i = e(g, h)
				}
				return i
			}
			return false
		},
		addrow : function(f, m, i) {
			if (m != undefined) {
				this._datachanged = true;
				if (i == undefined) {
					i = "last"
				}
				var l = false;
				var k = this;
				if (f == null) {
					if (!b.isArray(m)) {
						f = this.dataview.getid(this.dataview.source.id, m, this.dataview.totalrecords)
					} else {
						var d = new Array();
						b.each(m, function(e, n) {
							var o = k.dataview.getid(k.dataview.source.id, m[e], k.dataview.totalrecords + e);
							d.push(o)
						});
						f = d
					}
				}
				var g = function(o, n, r, e) {
					var q = o.vScrollInstance.value;
					var p = false;
					if (!b.isArray(r)) {
						p = o.dataview.addrow(n, r, e)
					} else {
						b.each(r, function(s, t) {
							var u = null;
							if (n != null && n[s] != null) {
								u = n[s]
							}
							p = o.dataview.addrow(u, this, e, false)
						});
						o.dataview.refresh()
					}
					if (o._updating == undefined || o._updating == false) {
						o._render(true, true, false, false);
						o.invalidate()
					}
					if (o.source && o.source._knockoutdatasource && !o._updateFromAdapter && o.autokoupdates) {
						if (o.source._source._localdata) {
							o.source.suspendKO = true;
							o.source._source._localdata.push(r);
							o.source.suspendKO = false
						}
					}
					o.vScrollInstance.setPosition(q);
					return p
				};
				if (this.source.addrow) {
					var h = function(e, n) {
						if (e == true || e == undefined) {
							if (n != undefined) {
								f = n
							}
							g(k, f, m, i)
						}
					};
					try {
						l = this.source.addrow(f, m, i, h);
						if (l == undefined) {
							l = true
						}
					} catch (j) {
						l = false
					}
					if (l == false) {
						return false
					}
				} else {
					g(this, f, m, i)
				}
				return l
			}
			return false
		},
		_findvisiblerow : function(g, h) {
			if (g == undefined) {
				g = parseInt(this.vScrollInstance.value)
			}
			var e = 0;
			if (h == undefined || h == null) {
				h = this.rows.records
			}
			var d = h.length;
			while (e <= d) {
				mid = parseInt((e + d) / 2);
				var f = h[mid];
				if (f == undefined) {
					break
				}
				if (f.top > g && f.top + f.height > g) {
					d = mid - 1
				} else {
					if (f.top < g && f.top + f.height < g) {
						e = mid + 1
					} else {
						return mid;
						break
					}
				}
			}
			return -1
		},
		_updatecellwidths : function() {
			var f = this.virtualsizeinfo;
			var p = this;
			if (this.gridcontent == undefined) {
				return
			}
			if (this.table == undefined) {
				this.table = this.gridcontent.find("#contenttable" + this.element.id)
			}
			var k = this.groupable && this.groups.length > 0;
			var q = 0;
			var l = f.visiblerecords;
			if (this.pageable && this.autoheight) {
				l = this.dataview.pagesize;
				if (this.groupable) {
					this.dataview.updateview();
					l = this.dataview.rows.length
				}
			}
			if (!this.pageable && this.autoheight) {
				l = this.dataview.totalrecords
			}
			if (this.rowdetails) {
				l += this.dataview.pagesize
			}
			var r = this.columns.records.length;
			var t = this.table[0].rows;
			for ( var n = 0; n < l; n++) {
				var d = t[n];
				if (!d) {
					break
				}
				var s = d.cells;
				var h = 0;
				for ( var m = 0; m < r; m++) {
					var g = this.columns.records[m];
					var e = g.width;
					var o = b(s[m]);
					if (parseInt(o[0].style.left) != h) {
						o.css("left", h)
					}
					if (parseInt(o[0].style.width) != e) {
						o.width(e)
					}
					o[0].left = h;
					if (!(g.hidden && g.hideable)) {
						h += e
					} else {
						o.css("display", "none")
					}
				}
				if (q == 0) {
					this.table.width(parseInt(h) + 2);
					q = h
				}
			}
			if (this.showaggregates && this._updateaggregates) {
				this._updateaggregates()
			}
			if (this.showfilterrow && this.filterable && this._updatefilterrowui) {
				this._updatefilterrowui()
			}
			this._updatescrollbarsafterrowsprerender()
		},
		_updatescrollbarsafterrowsprerender : function() {
			var d = this.hScrollBar.css("visibility");
			var f = 0;
			if (this.vScrollBar.css("visibility") == "visible") {
				f = this.scrollbarsize + 3
			}
			if (this.table.width() - 2 > this.host.width() - f) {
				if (d != "visible") {
					this.hScrollBar.css("visibility", "visible");
					this._arrange()
				}
				if (this.vScrollBar.css("visibility") == "visible") {
					if (this.scrollmode != "deferred") {
						var e = this.vScrollBar.jqxScrollBar("max");
						this.vScrollBar.jqxScrollBar("max", e + this.scrollbarsize + 4)
					}
				}
				this.hScrollBar.jqxScrollBar("max", f + this.table.width() - this.host.width())
			} else {
				if (d != "hidden") {
					this.hScrollBar.css("visibility", "hidden");
					this._arrange()
				}
			}
			this._renderhorizontalscroll()
		},
		_prerenderrows : function(o) {
			var B = this;
			if (this.prerenderrequired == true) {
				this.prerenderrequired = false;
				if (this.editable && this._destroyeditors) {
					this._destroyeditors()
				}
				if (this.gridcontent == undefined) {
					return
				}
				this.gridcontent.find("#contenttable" + this.element.id).remove();
				if (this.table != null) {
					this.table.remove();
					this.table = null
				}
				this.table = b('<div id="contenttable' + this.element.id + '" style="overflow: hidden; position: relative;" height="100%"></div>');
				this.gridcontent.addClass(this.toTP("jqx-grid-content"));
				this.gridcontent.addClass(this.toTP("jqx-widget-content"));
				this.gridcontent.append(this.table);
				var A = this.groupable && this.groups.length > 0;
				var p = 0;
				this.table[0].rows = new Array();
				var l = this.toTP("jqx-grid-cell");
				if (A) {
					l = " " + this.toTP("jqx-grid-group-cell")
				}
				var u = o.visiblerecords;
				if (this.pageable && this.autoheight) {
					u = this.dataview.pagesize;
					if (this.groupable) {
						this.dataview.updateview();
						u = this.dataview.rows.length
					}
				}
				if (!this.pageable && this.autoheight) {
					u = this.dataview.totalrecords
				}
				if (this.groupable && this.autoheight && !this.pageable) {
					u = this.dataview.rows.length
				}
				if (this.rowdetails) {
					u += this.dataview.pagesize
				}
				var z = this.columns.records.length;
				if (b.jqx.browser.msie && b.jqx.browser.version > 8) {
					this.table.css("opacity", "0.99")
				}
				if (b.jqx.browser.mozilla) {
					this.table.css("opacity", "0.99")
				}
				if (navigator.userAgent.indexOf("Safari") != -1) {
					this.table.css("opacity", "0.99")
				}
				var r = b.jqx.browser.msie && b.jqx.browser.version < 8;
				if (r) {
					this.host.attr("hideFocus", "true")
				}
				var k = this.tableZIndex;
				if (u * z > k) {
					k = u * z
				}
				var g = this.dataview.records.length == 0;
				var n = this.isTouchDevice();
				var v = "";
				for ( var y = 0; y < u; y++) {
					var s = '<div style="position: relative; height=' + this.rowsheight + 'px;" id="row' + y + this.element.id + '">';
					if (r) {
						var s = '<div style="position: relative; z-index: ' + k + "; height:" + this.rowsheight + 'px;" id="row' + y + this.element.id + '">';
						k--
					}
					var f = 0;
					for ( var w = 0; w < z; w++) {
						var x = this.columns.records[w];
						var t = x.width;
						if (t < x.minwidth) {
							t = x.minwidth
						}
						if (t > x.maxwidth) {
							t = x.maxwidth
						}
						if (this.rtl) {
							var q = k - z + 2 * w;
							var d = '<div style="overflow: hidden; position: absolute; height: 100%; left: ' + f + "px; z-index: " + q + "; width:" + t + "px;";
							k--
						} else {
							var d = '<div style="overflow: hidden; position: absolute; height: 100%; left: ' + f + "px; z-index: " + k-- + "; width:" + t + "px;"
						}
						if (!(x.hidden && x.hideable)) {
							f += t
						} else {
							d += "display: none;";
							k++
						}
						d += '" class="' + l + '"></div>';
						s += d
					}
					if (p == 0) {
						this.table.width(parseInt(f) + 2);
						p = f
					}
					s += "</div>";
					v += s
				}
				if (B.WinJS) {
					MSApp.execUnsafeLocalFunction(function() {
						B.table.html(v)
					})
				} else {
					B.table[0].innerHTML = v
				}
				this.table[0].rows = new Array();
				var m = this.table.children();
				for ( var y = 0; y < u; y++) {
					var h = m[y];
					this.table[0].rows.push(h);
					h.cells = new Array();
					var e = b(h).children();
					for ( var w = 0; w < z; w++) {
						h.cells.push(e[w])
					}
				}
				if (u == 0) {
					var f = 0;
					if (this.showemptyrow) {
						var s = b('<div style="position: relative;" id="row0' + this.element.id + '"></div>');
						this.table.append(s);
						s.height(this.rowsheight);
						this.table[0].rows[0] = s[0];
						this.table[0].rows[0].cells = new Array()
					}
					for ( var w = 0; w < z; w++) {
						var x = this.columns.records[w];
						var t = x.width;
						if (this.showemptyrow) {
							var d = b('<div style="position: absolute; height: 100%; left: ' + f + "px; z-index: " + k-- + "; width:" + t + 'px;" class="' + l + '"></div>');
							d.height(this.rowsheight);
							s.append(d);
							this.table[0].rows[0].cells[w] = d[0]
						}
						if (t < x.minwidth) {
							t = x.minwidth
						}
						if (t > x.maxwidth) {
							t = x.maxwidth
						}
						if (!(x.hidden && x.hideable)) {
							f += t
						}
					}
					this.table.width(parseInt(f) + 2);
					p = f
				}
				this._updatescrollbarsafterrowsprerender();
				if (this.rendered) {
					this.rendered("rows")
				}
				this._addoverlayelement()
			}
		},
		_groupsheader : function() {
			return this.groupable && this.showgroupsheader
		},
		_arrange : function() {
			var t = null;
			var q = null;
			this.tableheight = null;
			var w = this;
			var k = false;
			var j = false;
			if (this.width != null && this.width.toString().indexOf("px") != -1) {
				t = this.width
			} else {
				if (this.width != undefined && !isNaN(this.width)) {
					t = this.width
				}
			}
			if (this.width != null && this.width.toString().indexOf("%") != -1) {
				t = this.width;
				k = true
			}
			if (this.height != null && this.height.toString().indexOf("px") != -1) {
				q = this.height
			} else {
				if (this.height != undefined && !isNaN(this.height)) {
					q = this.height
				}
			}
			if (this.height != null && this.height.toString().indexOf("%") != -1) {
				q = this.height;
				j = true
			}
			var i = function() {
				var x = 0;
				var y = w.showheader ? w.columnsheader != null ? w.columnsheader.height() + 2 : 0 : 0;
				x += y;
				if (w.pageable) {
					x += w.pagerheight
				}
				if (w._groupsheader()) {
					x += w.groupsheaderheight
				}
				if (w.showtoolbar) {
					x += w.toolbarheight
				}
				if (w.showstatusbar) {
					x += w.statusbarheight
				}
				if (w.hScrollBar[0].style.visibility == "visible") {
					x += 20
				}
				return x
			};
			if (this.autoheight && this.virtualsizeinfo) {
				if (this.pageable && this.gotopage) {
					var u = 0;
					q = u + (this._pageviews[0] ? this._pageviews[0].height : 0);
					q += i();
					if (this.showemptyrow && this.dataview.totalrecords == 0) {
						q += this.rowsheight
					}
				} else {
					var u = this.host.height() - this._gettableheight();
					if (this._pageviews.length > 0) {
						q = u + this._pageviews[this._pageviews.length - 1].height + this._pageviews[this._pageviews.length - 1].top;
						this.vScrollBar[0].style.visibility = "hidden"
					} else {
						q = i();
						if (this.showemptyrow) {
							q += this.rowsheight
						}
					}
				}
			} else {
				if (this.autoheight) {
					q = this.dataview.totalrecords * this.rowsheight;
					if (this._loading) {
						q = 250;
						this.dataloadelement.height(q)
					}
					q += i();
					if (q > 10000) {
						q = 10000
					}
				}
			}
			var e = this.host.css("border-width");
			if (e == null) {
				e = 0
			}
			if (t != null) {
				t = parseInt(t);
				this.host.width(this.width);
				if (k) {
					t = this.host.width();
					if (t <= 2) {
						t = 600;
						this.host.width(t)
					}
					if (!this._oldWidth) {
						this._oldWidth = t
					}
				}
			} else {
				this.host.width(250)
			}
			if (q != null) {
				if (!j) {
					q = parseInt(q)
				}
				this.host.height(q);
				if (j && !this.autoheight) {
					q = this.host.height();
					if (q == 0) {
						q = 400;
						this.host.height(q)
					}
					if (!this._oldHeight) {
						this._oldHeight = q
					}
				}
			} else {
				this.host.height(250)
			}
			if (this.autoheight) {
				this.tableheight = null;
				this._gettableheight()
			}
			var p = 0;
			if (this.showtoolbar) {
				this.toolbar.width(t);
				this.toolbar.height(this.toolbarheight - 1);
				this.toolbar.css("top", 0);
				p += this.toolbarheight;
				q -= parseInt(this.toolbarheight)
			} else {
				this.toolbar.height(0)
			}
			if (this.showstatusbar) {
				this.statusbar.width(!this.table ? t : Math.max(t, this.table.width()));
				this.statusbar.height(this.statusbarheight - 1)
			} else {
				this.statusbar.height(0)
			}
			if (this._groupsheader()) {
				this.groupsheader.width(t);
				this.groupsheader.height(this.groupsheaderheight);
				this.groupsheader.css("top", p);
				var r = this.groupsheader.height() + 1;
				p += r;
				if (q > r) {
					q -= parseInt(r)
				}
			} else {
				this.groupsheader.width(t);
				this.groupsheader.height(this.groupsheaderheight);
				this.groupsheader.css("top", p);
				this.content.css("top", p + this.groupsheader.height())
			}
			var d = this.scrollbarsize;
			if (isNaN(d)) {
				d = parseInt(d);
				if (isNaN(d)) {
					d = "17px"
				} else {
					d = d + "px"
				}
			}
			d = parseInt(d);
			var m = 4;
			var g = 2;
			var h = 0;
			if (this.vScrollBar[0].style.visibility == "visible") {
				h = d + m
			}
			if (this.hScrollBar[0].style.visibility == "visible") {
				g = d + m + 2
			}
			var n = 0;
			if (this.pageable) {
				n = this.pagerheight;
				g += this.pagerheight
			}
			if (this.showstatusbar) {
				g += this.statusbarheight;
				n += this.statusbarheight
			}
			this.hScrollBar.height(d);
			this.hScrollBar.css({
				top : p + q - m - d - n + "px",
				left : "0px"
			});
			this.hScrollBar.width(t - d - m + "px");
			if (h == 0) {
				this.hScrollBar.width(t - 2)
			}
			this.vScrollBar.width(d);
			this.vScrollBar.height(parseInt(q) - g + "px");
			this.vScrollBar.css({
				left : parseInt(t) - parseInt(d) - m + "px",
				top : p
			});
			if (this.rtl) {
				this.vScrollBar.css({
					left : "0px",
					top : p
				});
				if (this.vScrollBar.css("visibility") != "hidden") {
					this.hScrollBar.css({
						left : d + 2
					})
				}
			}
			var l = this.vScrollInstance;
			l.disabled = this.disabled;
			l.refresh();
			var s = this.hScrollInstance;
			s.disabled = this.disabled;
			s.refresh();
			var o = function(x) {
				if ((x.vScrollBar[0].style.visibility == "visible") && (x.hScrollBar[0].style.visibility == "visible")) {
					x.bottomRight[0].style.visibility = "visible";
					x.bottomRight.css({
						left : 1 + parseInt(x.vScrollBar.css("left")),
						top : parseInt(x.hScrollBar.css("top"))
					});
					if (x.rtl) {
						x.bottomRight.css("left", "0px")
					}
					x.bottomRight.width(parseInt(d) + 3);
					x.bottomRight.height(parseInt(d) + 4);
					if (x.showaggregates) {
						x.bottomRight.css("z-index", 99);
						x.bottomRight.height(parseInt(d) + 4 + x.statusbarheight);
						x.bottomRight.css({
							top : parseInt(x.hScrollBar.css("top")) - x.statusbarheight
						})
					}
				} else {
					x.bottomRight[0].style.visibility = "hidden"
				}
			};
			o(this);
			this.content.width(t - h);
			this.content.height(q - g + 2);
			this.content.css("top", p);
			if (this.rtl) {
				this.content.css("left", h)
			}
			if (this.showstatusbar) {
				this.statusbar.css("top", p + q - this.statusbarheight - (this.pageable ? this.pagerheight : 0));
				if (this.showaggregates) {
					if (this.hScrollBar.css("visibility") == "visible") {
						this.hScrollBar.css({
							top : p + q - m - d - n + this.statusbarheight + "px"
						});
						this.statusbar.css("top", 1 + p + q - d - 5 - this.statusbarheight - (this.pageable ? this.pagerheight : 0))
					}
					o(this)
				}
			}
			if (this.pageable) {
				this.pager.width(t);
				this.pager.height(this.pagerheight);
				this.pager.css("top", p + q - this.pagerheight)
			} else {
				this.pager.height(0)
			}
			if (this.table != null) {
				var f = 0;
				if (this.vScrollBar[0].style.visibility == "visible") {
					f = this.scrollbarsize + 3
				}
				var v = f + this.table.width() - this.host.width();
				this.hScrollBar.jqxScrollBar("max", v);
				if (this.hScrollBar[0].style.visibility == "visible" && v == 0) {
					this.hScrollBar[0].style.visibility = "hidden";
					this._arrange()
				}
			}
			this.dataloadelement.width(this.host.width());
			this.dataloadelement.height(this.host.height());
			this._hostwidth = this.host.width()
		},
		destroy : function() {
			if (this.host.jqxDropDownList) {
				var g = b(b.find("#filterclearbutton" + this.element.id));
				var f = b(b.find("#filterbutton" + this.element.id));
				var j = b(b.find("#filter1" + this.element.id));
				var e = b(b.find("#filter2" + this.element.id));
				var i = b(b.find("#filter3" + this.element.id));
				var h = b(b.find(".filtertext1" + this.element.id));
				var d = b(b.find(".filtertext2" + this.element.id));
				if (h.length > 0 && d.length > 0) {
					h.removeClass();
					d.removeClass();
					h.remove();
					d.remove()
				}
				this.removeHandler(g, "click");
				this.removeHandler(f, "click");
				j.jqxDropDownList("destroy");
				e.jqxDropDownList("destroy");
				i.jqxDropDownList("destroy")
			}
			if (this.editable && this._destroyeditors) {
				this._destroyeditors()
			}
			if (this.filterable && this._destroyedfilters && this.showfilterrow) {
				this._destroyedfilters()
			}
			if (this.host.jqxMenu) {
				if (this.gridmenu) {
					this.removeHandler(b(document), "click.menu" + this.element.id);
					this.removeHandler(this.gridmenu, "keydown");
					this.removeHandler(this.gridmenu, "closed");
					this.removeHandler(this.gridmenu, "itemclick");
					this.gridmenu.jqxMenu("destroy")
				}
			}
			if (this.pagershowrowscombo) {
				this.pagershowrowscombo.jqxDropDownList("destroy")
			}
			if (this.pagerrightbutton) {
				this.removeHandler(this.pagerrightbutton, "mousedown");
				this.removeHandler(this.pagerrightbutton, "mouseup");
				this.removeHandler(this.pagerrightbutton, "click");
				this.pagerrightbutton.jqxButton("destroy")
			}
			if (this.pagerleftbutton) {
				this.removeHandler(this.pagerleftbutton, "mousedown");
				this.removeHandler(this.pagerleftbutton, "mouseup");
				this.removeHandler(this.pagerleftbutton, "click");
				this.pagerleftbutton.jqxButton("destroy");
				this.removeHandler(b(document), "mouseup.pagerbuttons" + this.element.id)
			}
			this.removeHandler(b(document), "mousedown.resize" + this.element.id);
			this.removeHandler(b(document), "mouseup.resize" + this.element.id);
			this.removeHandler(b(document), "mousemove.resize" + this.element.id);
			this.removeHandler(b(document), "mousedown.reorder" + this.element.id);
			this.removeHandler(b(document), "mouseup.reorder" + this.element.id);
			this.removeHandler(b(document), "mousemove.reorder" + this.element.id);
			this.columns = new b.jqx.collection(this.element);
			this.rows = new b.jqx.collection(this.element);
			this.hScrollInstance.destroy();
			this.vScrollInstance.destroy();
			this.hScrollBar.remove();
			this.vScrollBar.remove();
			this._removeHandlers();
			this._clearcaches();
			this.dataview._clearcaches();
			this.content.removeClass();
			this.content.remove();
			this.content = null;
			this.vScrollBar = null;
			this.hScrollBar = null;
			if (this.gridmenu) {
				this.gridmenu = null
			}
			this.host.removeData();
			this.host.removeClass();
			this.host.remove();
			this.host = null
		},
		_initializeColumns : function() {
			if (this.autogeneratecolumns) {
				var k = new Array();
				var e = this.source.datafields;
				if (e == null && this.source._source) {
					e = this.source._source.datafields
				}
				b.each(e, function() {
					var i = {
						datafield : this.name,
						text : this.text || this.name,
						cellsformat : this.format || ""
					};
					k.push(i)
				});
				this.columns = k
			}
			if (this.columns && this.columns.records) {
				for ( var f = 0; f < this.columns.records.length; f++) {
					this._removecolumnhandlers(this.columns.records[f])
				}
			}
			var j = this;
			var d = new b.jqx.collection(this.element);
			var h = 0;
			this._haspinned = false;
			if (!this._columns) {
				this._columns = this.columns
			} else {
				this.columns = this._columns
			}
			if (this.groupable) {
				b.each(this.groups, function(i) {
					var l = new c(j, this);
					l.visibleindex = h++;
					l.width = j.groupindentwidth;
					d.add(l);
					l.pinned = true
				});
				j._haspinned = true
			}
			if (this.rowdetails && this.showrowdetailscolumn) {
				var g = new c(j, this);
				g.visibleindex = h++;
				g.width = j.groupindentwidth;
				g.pinned = true;
				d.add(g);
				j._haspinned = true
			}
			b.each(this.columns, function(i) {
				if (j.columns[i] != undefined) {
					var l = new c(j, this);
					l.visibleindex = h++;
					if (this.dataField != undefined) {
						this.datafield = this.dataField
					}
					if (this.pinned) {
						j._haspinned = true
					}
					if (this.datafield == null) {
						if (j.source && j.source._source && (j.source._source.datatype == "array")) {
							this.datafield = i.toString();
							l.datafield = this.datafield
						}
					}
					d.add(l)
				}
			});
			if (this.rtl) {
				d.records.reverse()
			}
			this.columns = d
		},
		_initializeRows : function() {
			var d = new b.jqx.collection(this.element);
			if (this.rows) {
				this.rows.clear()
			}
			this.rows = d
		},
		_raiseEvent : function(h, e) {
			if (e == undefined) {
				e = {
					owner : null
				}
			}
			var f = this.events[h];
			args = e;
			args.owner = this;
			var g = new jQuery.Event(f);
			g.owner = this;
			g.args = args;
			var d = this.host.trigger(g);
			e = g.args;
			return d
		},
		wheel : function(f, e) {
			if (e.autoheight && e.hScrollBar.css("visibility") != "visible") {
				f.returnValue = true;
				return true
			}
			var g = 0;
			if (!f) {
				f = window.event
			}
			if (f.originalEvent && f.originalEvent.wheelDelta) {
				f.wheelDelta = f.originalEvent.wheelDelta
			}
			if (f.wheelDelta) {
				g = f.wheelDelta / 120
			} else {
				if (f.detail) {
					g = -f.detail / 3
				}
			}
			if (g) {
				var d = e._handleDelta(g);
				if (d) {
					if (f.preventDefault) {
						f.preventDefault()
					}
					if (f.originalEvent != null) {
						f.originalEvent.mouseHandled = true
					}
					if (f.stopPropagation != undefined) {
						f.stopPropagation()
					}
				}
				if (d) {
					d = false;
					f.returnValue = d;
					return d
				} else {
					return false
				}
			}
			if (f.preventDefault) {
				f.preventDefault()
			}
			f.returnValue = false
		},
		_handleDelta : function(f) {
			if (this.vScrollBar.css("visibility") != "hidden") {
				var e = this.vScrollInstance.value;
				if (f < 0) {
					this.scrollDown()
				} else {
					this.scrollUp()
				}
				var d = this.vScrollInstance.value;
				if (e != d) {
					return true
				}
			} else {
				if (this.hScrollBar.css("visibility") != "hidden") {
					var e = this.hScrollInstance.value;
					if (f > 0) {
						if (this.hScrollInstance.value > 2 * this.horizontalscrollbarstep) {
							this.hScrollInstance.setPosition(this.hScrollInstance.value - 2 * this.horizontalscrollbarstep)
						} else {
							this.hScrollInstance.setPosition(0)
						}
					} else {
						if (this.hScrollInstance.value < this.hScrollInstance.max) {
							this.hScrollInstance.setPosition(this.hScrollInstance.value + 2 * this.horizontalscrollbarstep)
						} else {
							this.hScrollInstance.setPosition(this.hScrollInstance.max)
						}
					}
					var d = this.hScrollInstance.value;
					if (e != d) {
						return true
					}
				}
			}
			return false
		},
		scrollDown : function() {
			if (this.vScrollBar.css("visibility") == "hidden") {
				return
			}
			var d = this.vScrollInstance;
			if (d.value + this.rowsheight <= d.max) {
				d.setPosition(parseInt(d.value) + this.rowsheight)
			} else {
				d.setPosition(d.max)
			}
		},
		scrollUp : function() {
			if (this.vScrollBar.css("visibility") == "hidden") {
				return
			}
			var d = this.vScrollInstance;
			if (d.value - this.rowsheight >= d.min) {
				d.setPosition(parseInt(d.value) - this.rowsheight)
			} else {
				d.setPosition(d.min)
			}
		},
		_removeHandlers : function() {
			var d = this;
			this.removeHandler(this.vScrollBar, "valuechanged");
			this.removeHandler(this.hScrollBar, "valuechanged");
			this.vScrollInstance.valuechanged = null;
			this.hScrollInstance.valuechanged = null;
			var e = "mousedown";
			if (this.isTouchDevice()) {
				e = b.jqx.mobile.getTouchEventName("touchend")
			}
			this.removeHandler(this.host, "dblclick");
			this.removeHandler(this.host, e);
			this.removeHandler(this.content, "mousemove", this._mousemovefunc);
			this.removeHandler(this.host, "mouseleave");
			this.removeHandler(this.content, "mouseenter");
			this.removeHandler(this.content, "mouseleave");
			this.removeHandler(this.content, "selectstart." + this.element.id);
			this.removeHandler(this.host, "dragstart." + this.element.id);
			this.removeHandler(this.host, "keydown.edit" + this.element.id);
			this.removeHandler(b(document), "keydown.edit" + this.element.id);
			this.removeHandler(b(document), "mousemove.selection" + this.element.id);
			this.removeHandler(b(document), "mouseup.selection" + this.element.id);
			if (this.editable) {
				this.removeHandler(b(document), "mousedown.gridedit" + this.element.id)
			}
		},
		_addHandlers : function() {
			var e = this;
			var d = e.isTouchDevice();
			if (!d) {
				this.addHandler(this.host, "dragstart." + this.element.id, function(i) {
					return false
				})
			}
			if (this.editable) {
				this.addHandler(b(document), "mousedown.gridedit" + this.element.id, function(l) {
					if (e.editable && e.begincelledit) {
						if (e.editcell) {
							if (!e.vScrollInstance.isScrolling() && !e.vScrollInstance.isScrolling()) {
								var j = e.host.offset();
								var m = e.host.width();
								var k = e.host.height();
								var n = false;
								if (l.pageY < j.top || l.pageY > j.top + k) {
									n = true
								}
								if (l.pageX < j.left || l.pageX > j.left + m) {
									n = true
								}
								if (n) {
									var i = false;
									if (e.editcell && e.editcell.editor) {
										switch (e.editcell.columntype) {
										case "datetimeinput":
											if (e.editcell.editor.jqxDateTimeInput && e.editcell.editor.jqxDateTimeInput("container")[0].style.display == "block") {
												e.editcell.editor.jqxDateTimeInput("close")
											}
											break;
										case "combobox":
											if (e.editcell.editor.jqxComboBox && e.editcell.editor.jqxComboBox("container")[0].style.display == "block") {
												e.editcell.editor.jqxComboBox("close")
											}
											break;
										case "dropdownlist":
											if (e.editcell.editor.jqxDropDownList && e.editcell.editor.jqxDropDownList("container")[0].style.display == "block") {
												e.editcell.editor.jqxDropDownList("close")
											}
											break
										}
									}
									e.endcelledit(e.editcell.row, e.editcell.column, false, true)
								}
							}
						}
					}
				})
			}
			this.vScrollInstance.valuechanged = function(i) {
				if (e.virtualsizeinfo) {
					e._closemenu();
					if (e.scrollmode != "physical") {
						e._renderrows(e.virtualsizeinfo);
						e.currentScrollValue = i.currentValue
					} else {
						if (e.currentScrollValue != undefined && Math.abs(e.currentScrollValue - i.currentValue) >= 5) {
							e._renderrows(e.virtualsizeinfo);
							e.currentScrollValue = i.currentValue
						} else {
							e._renderrows(e.virtualsizeinfo);
							e.currentScrollValue = i.currentValue
						}
					}
					if (!e.pageable && !e.groupable && e.dataview.virtualmode) {
						if (e.loadondemandupdate) {
							clearTimeout(e.loadondemandupdate)
						}
						e.loadondemandupdate = setTimeout(function() {
							e.loadondemand = true;
							e._renderrows(e.virtualsizeinfo)
						}, 100)
					}
					if (d) {
						e._lastScroll = new Date()
					}
				}
			};
			this.hScrollInstance.valuechanged = function(k) {
				if (e.virtualsizeinfo) {
					e._closemenu();
					var j = function() {
						e._renderhorizontalscroll();
						e._renderrows(e.virtualsizeinfo);
						if (e.editcell && !e.editrow) {
							if (e._showcelleditor && e.editcell.editing) {
								if (!e.hScrollInstance.isScrolling()) {
									e._showcelleditor(e.editcell.row, e.getcolumn(e.editcell.column), e.editcell.element, e.editcell.init)
								}
							}
						}
					};
					var i = e._browser == undefined ? e._isIE10() : e._browser;
					if (navigator && navigator.userAgent.indexOf("Safari") != -1) {
						if (e._hScrollTimer) {
							clearTimeout(e._hScrollTimer)
						}
						e._hScrollTimer = setTimeout(function() {
							j()
						}, 1)
					} else {
						if (b.jqx.browser.mozilla || b.jqx.browser.msie) {
							if (e._hScrollTimer) {
								clearTimeout(e._hScrollTimer)
							}
							e._hScrollTimer = setTimeout(function() {
								j()
							}, 0.01)
						} else {
							j()
						}
					}
					if (d) {
						e._lastScroll = new Date()
					}
				}
			};
			this._mousewheelfunc = this._mousewheelfunc || function(i) {
				if (!e.editcell && e.enablemousewheel) {
					e.wheel(i, e);
					return false
				}
			};
			this.removeHandler(this.host, "mousewheel", this._mousewheelfunc);
			this.addHandler(this.host, "mousewheel", this._mousewheelfunc);
			var g = "mousedown";
			if (d) {
				g = b.jqx.mobile.getTouchEventName("touchend")
			}
			this.addHandler(this.host, g, function(j) {
				if (e.isTouchDevice()) {
					e._newScroll = new Date();
					if (e._newScroll - e._lastScroll < 500) {
						return false
					}
					if (b(j.target).ischildof(e.vScrollBar)) {
						return false
					}
					if (b(j.target).ischildof(e.hScrollBar)) {
						return false
					}
				}
				e._mousedown = new Date();
				var i = e._handlemousedown(j, e);
				if (e.isNestedGrid) {
					if (!e.resizablecolumn && !e.columnsreorder) {
						j.stopPropagation()
					}
				}
				e._lastmousedown = new Date();
				return i
			});
			if (!d) {
				this.addHandler(this.host, "dblclick", function(j) {
					if (e.editable && e.begincelledit && e.editmode == "dblclick") {
						e._handledblclick(j, e)
					} else {
						if (b.jqx.browser.msie && b.jqx.browser.version < 9) {
							var i = e._handlemousedown(j, e)
						}
					}
					e.mousecaptured = false;
					e._lastmousedown = new Date();
					return true
				});
				this._mousemovefunc = function(i) {
					if (e._handlemousemove) {
						return e._handlemousemove(i, e)
					}
				};
				this.addHandler(this.content, "mousemove", this._mousemovefunc);
				this.addHandler(b(document), "mousemove.selection" + this.element.id, function(i) {
					if (e._handlemousemoveselection) {
						return e._handlemousemoveselection(i, e)
					}
				});
				this.addHandler(b(document), "mouseup.selection" + this.element.id, function(i) {
					if (e._handlemouseupselection) {
						e._handlemouseupselection(i, e)
					}
				})
			}
			if (document.referrer != "" || window.frameElement) {
				if (window.top != null && window.top != window.self) {
					var h = null;
					if (window.parent && document.referrer) {
						h = document.referrer
					}
					if (h && h.indexOf(document.location.host) != -1) {
						var f = function(i) {
							if (e._handlemouseupselection) {
								e._handlemouseupselection(i, e)
							}
						};
						if (window.top.document.addEventListener) {
							window.top.document.addEventListener("mouseup", f, false)
						} else {
							if (window.top.document.attachEvent) {
								window.top.document.attachEvent("onmouseup", f)
							}
						}
					}
				}
			}
			this.focused = false;
			if (!d) {
				this.addHandler(this.content, "mouseenter", function(i) {
					e.focused = true;
					if (e._overlayElement) {
						if (e.vScrollInstance.isScrolling() || e.hScrollInstance.isScrolling()) {
							e._overlayElement[0].style.visibility = "visible"
						} else {
							e._overlayElement[0].style.visibility = "hidden"
						}
					}
				});
				this.addHandler(this.content, "mouseleave", function(i) {
					if (e._handlemousemove) {
						if (e.enablehover) {
							e._clearhoverstyle()
						}
					}
					if (e._overlayElement) {
						e._overlayElement[0].style.visibility = "hidden"
					}
					e.focused = false
				});
				this.addHandler(this.content, "selectstart." + this.element.id, function(i) {
					if (e.enablebrowserselection) {
						return true
					}
					if (!e.editcell && !e.showfilterrow) {
						return false
					}
				});
				this.addHandler(b(document), "keydown.edit" + this.element.id, function(k) {
					var j = k.charCode ? k.charCode : k.keyCode ? k.keyCode : 0;
					if (e.handlekeyboardnavigation) {
						var l = e.handlekeyboardnavigation(k);
						if (l == true) {
							return false
						}
					}
					if (e.editable && e.editcell) {
						if (j == 13 || j == 27) {
							if (e._handleeditkeydown) {
								i = e._handleeditkeydown(k, e)
							}
						}
					}
					if (j == 27) {
						e.mousecaptured = false;
						if (e.selectionarea.css("visibility") == "visible") {
							e.selectionarea.css("visibility", "hidden")
						}
					}
					if (b.jqx.browser.msie && e.focused && !e.isNestedGrid) {
						var i = true;
						var j = k.charCode ? k.charCode : k.keyCode ? k.keyCode : 0;
						if (!e.editcell && e.editable && e.editmode != "programmatic") {
							if (e._handleeditkeydown) {
								i = e._handleeditkeydown(k, e)
							}
						}
						if (i && e.keyboardnavigation && e._handlekeydown) {
							i = e._handlekeydown(k, e);
							if (!i) {
								if (k.preventDefault) {
									k.preventDefault()
								}
								if (k.stopPropagation != undefined) {
									k.stopPropagation()
								}
							}
							return i
						}
					}
					return true
				});
				this.addHandler(this.host, "keydown.edit" + this.element.id, function(j) {
					var i = true;
					if (e.handlekeyboardnavigation) {
						var k = e.handlekeyboardnavigation(j);
						if (k == true) {
							return false
						}
					}
					if (e.editable && e.editmode != "programmatic") {
						if (e._handleeditkeydown) {
							i = e._handleeditkeydown(j, e)
						}
					}
					if (!b.jqx.browser.msie) {
						if (i && e.keyboardnavigation && e._handlekeydown) {
							i = e._handlekeydown(j, e);
							if (e.isNestedGrid) {
								j.stopPropagation()
							}
						}
					} else {
						if (e.isNestedGrid) {
							if (i && e.keyboardnavigation && e._handlekeydown) {
								i = e._handlekeydown(j, e);
								j.stopPropagation()
							}
						}
					}
					if (!i) {
						if (j.preventDefault) {
							j.preventDefault()
						}
						if (j.stopPropagation != undefined) {
							j.stopPropagation()
						}
					}
					return i
				})
			}
		},
		_hittestrow : function(s, q) {
			if (this.vScrollInstance == null || this.hScrollInstance == null) {
				return
			}
			if (s == undefined) {
				s = 0
			}
			if (q == undefined) {
				q == 0
			}
			var l = this.vScrollInstance;
			var k = this.hScrollInstance;
			var f = l.value;
			if (this.vScrollBar.css("visibility") != "visible") {
				f = 0
			}
			var m = k.value;
			if (this.hScrollBar.css("visibility") != "visible") {
				m = 0
			}
			if (this.scrollmode == "deferred" && this._newmax != null) {
				if (f > this._newmax) {
					f = this._newmax
				}
			}
			var r = parseInt(f) + q;
			var j = parseInt(m) + s;
			if (this.visiblerows == null) {
				return
			}
			var e = false;
			var i = this._findvisiblerow(r, this.visiblerows);
			if (i >= 0) {
				var o = this.visiblerows[i];
				var d = this.rowdetails && o.rowdetails;
				var n = !o.rowdetailshidden;
				if (d) {
					var g = this.visiblerows[i - 1];
					if (g == o) {
						o = g;
						i--
					}
					if (n) {
						var h = b(this.hittestinfo[i].visualrow).position().top + parseInt(this.table.css("top"));
						var p = b(this.hittestinfo[i].visualrow).height();
						if (!(q >= h && q <= h + p)) {
							i++;
							o = this.visiblerows[i];
							e = true
						}
					}
				}
			}
			return {
				index : i,
				row : o,
				details : e
			}
		},
		getcellatposition : function(j, q) {
			var r = this;
			var z = this.showheader ? this.columnsheader.height() + 2 : 0;
			var s = this._groupsheader() ? this.groupsheader.height() : 0;
			var B = this.showtoolbar ? this.toolbarheight : 0;
			s += B;
			var g = this.host.offset();
			if (this.hasTransform) {
				g = b.jqx.utilities.getOffset(this.host)
			}
			var p = j - g.left;
			var n = q - z - g.top - s;
			var d = this._hittestrow(p, n);
			var k = d.row;
			var l = d.index;
			var t = this.table[0].rows[l];
			if (this.dataview && this.dataview.records.length == 0) {
				var o = this.table[0].rows;
				var C = 0;
				for ( var w = 0; w < o.length; w++) {
					if (n >= C && n < C + this.rowsheight) {
						t = o[w];
						break
					}
					C += this.rowsheight
				}
				k = {
					boundindex : w
				}
			}
			if (t == null) {
				return true
			}
			var u = this.hScrollInstance;
			var v = u.value;
			var f = 0;
			var m = this.groupable ? this.groups.length : 0;
			for ( var w = 0; w < t.cells.length; w++) {
				var h = parseInt(b(this.columnsrow[0].cells[w]).css("left"));
				var j = h - v;
				if (r.columns.records[w].pinned) {
					j = h
				}
				var A = j + b(this.columnsrow[0].cells[w]).width();
				if (A >= p && p >= j) {
					f = w;
					break
				}
			}
			if (k != null) {
				var e = this._getcolumnat(f);
				return {
					row : k.boundindex,
					column : e.datafield,
					value : this.getcellvalue(k.boundindex, e.datafield)
				}
			}
			return null
		},
		_handlemousedown : function(G, z) {
			if (G.target == null) {
				return true
			}
			if (z.disabled) {
				return true
			}
			if (b(G.target).ischildof(this.columnsheader)) {
				return true
			}
			var J;
			if (G.which) {
				J = (G.which == 3)
			} else {
				if (G.button) {
					J = (G.button == 2)
				}
			}
			var O;
			if (G.which) {
				O = (G.which == 2)
			} else {
				if (G.button) {
					O = (G.button == 1)
				}
			}
			if (O) {
				return true
			}
			if (this.showstatusbar) {
				if (b(G.target).ischildof(this.statusbar)) {
					return true
				}
				if (G.target == this.statusbar[0]) {
					return true
				}
			}
			var I = this.showheader ? this.columnsheader.height() + 2 : 0;
			var A = this._groupsheader() ? this.groupsheader.height() : 0;
			var N = this.showtoolbar ? this.toolbarheight : 0;
			A += N;
			var h = this.host.offset();
			if (this.hasTransform) {
				h = b.jqx.utilities.getOffset(this.host)
			}
			var p = this._getBodyOffset();
			h.left += p.left;
			h.top += p.top;
			var k = parseInt(G.pageX);
			var w = parseInt(G.pageY);
			if (this.isTouchDevice()) {
				var v = z.getTouches(G);
				var o = v[0];
				k = parseInt(o.pageX);
				w = parseInt(o.pageY);
				if (z.touchmode == true) {
					k = parseInt(o._pageX);
					w = parseInt(o._pageY)
				}
			}
			var s = k - h.left;
			var r = w - I - h.top - A;
			var d = this._hittestrow(s, r);
			if (!d) {
				return
			}
			if (d.details) {
				return
			}
			var n = d.row;
			var m = d.index;
			var D = G.target.className;
			var B = this.table[0].rows[m];
			if (B == null) {
				if (z.editable && z.begincelledit) {
					if (z.editcell) {
						z.endcelledit(z.editcell.row, z.editcell.column, false, true)
					}
				}
				return true
			}
			z.mousecaptured = true;
			z.mousecaptureposition = {
				left : G.pageX,
				top : G.pageY - A,
				clickedrow : B
			};
			var C = this.hScrollInstance;
			var F = C.value;
			if (this.rtl) {
				if (this.hScrollBar.css("visibility") != "hidden") {
					F = C.max - C.value
				}
			}
			var g = -1;
			var q = this.groupable ? this.groups.length : 0;
			for ( var H = 0; H < B.cells.length; H++) {
				var j = parseInt(b(this.columnsrow[0].cells[H]).css("left"));
				var k = j - F;
				if (z.columns.records[H].pinned && !z.rtl) {
					k = j
				}
				var f = this._getcolumnat(H);
				if (f != null && f.hidden) {
					continue
				}
				var M = k + b(this.columnsrow[0].cells[H]).width();
				if (M >= s && s >= k) {
					g = H;
					z.mousecaptureposition.clickedcell = H;
					break
				}
			}
			if (n != null && g >= 0) {
				this._raiseEvent(1, {
					rowindex : n.boundindex,
					visibleindex : n.visibleindex,
					group : n.group,
					rightclick : J,
					originalEvent : G
				});
				var f = this._getcolumnat(g);
				var u = this.getcellvalue(n.boundindex, f.datafield);
				if (this.editable && this.editcell) {
					if (f.datafield == this.editcell.column) {
						if (n.boundindex == this.editcell.row) {
							this.mousecaptured = false
						}
					}
				}
				this._raiseEvent(8, {
					rowindex : n.boundindex,
					column : f ? f.getcolumnproperties() : null,
					datafield : f ? f.datafield : null,
					columnindex : g,
					value : u,
					rightclick : J,
					originalEvent : G
				});
				if (this.isTouchDevice()) {
					if (f.columntype == "checkbox" && this.editable && this._overlayElement) {
						if (!this.editcell) {
							this._overlayElement.css("visibility", "hidden");
							this.editcell = this.getcell(m, f.datafield);
							return true
						}
					} else {
						if (f.columntype == "button" && this._overlayElement) {
							if (f.buttonclick) {
								f.buttonclick(B.cells[g].buttonrow, G)
							}
							return true
						}
					}
				}
				var L = false;
				if (this._lastmousedown != null) {
					if (this._mousedown - this._lastmousedown < 300) {
						if (this._clickedrowindex == n.boundindex) {
							this._raiseEvent(22, {
								rowindex : n.boundindex,
								visibleindex : n.visibleindex,
								group : n.group,
								rightclick : J,
								originalEvent : G
							});
							if (this._clickedcolumn == f.datafield) {
								this._raiseEvent(23, {
									rowindex : n.boundindex,
									column : f ? f.getcolumnproperties() : null,
									datafield : f ? f.datafield : null,
									columnindex : g,
									value : u,
									rightclick : J,
									originalEvent : G
								})
							}
							L = true;
							this._clickedrowindex = -1;
							this._clickedcolumn = null;
							if (G.isPropagationStopped && G.isPropagationStopped()) {
								return false
							}
						}
					}
				}
				if (J) {
					return true
				}
				if (!L) {
					this._clickedrowindex = n.boundindex;
					this._clickedcolumn = f.datafield
				}
				var E = b.jqx.utilities.getBrowser();
				if (E.browser == "msie" && parseInt(E.version) <= 7) {
					if (g == 0 && this.rowdetails) {
						D = "jqx-grid-group-collapse"
					}
					if (q > 0) {
						if (g <= q) {
							D = "jqx-grid-group-collapse"
						}
					}
				}
				if (D.indexOf("jqx-grid-group-expand") != -1 || D.indexOf("jqx-grid-group-collapse") != -1) {
					if (!this.rtl) {
						if (q > 0 && g < q && this._togglegroupstate) {
							this._togglegroupstate(n.bounddata, true)
						} else {
							if (g == q && this.rowdetails && this.showrowdetailscolumn) {
								this._togglerowdetails(n.bounddata, true);
								this.gridcontent[0].scrollTop = 0;
								this.gridcontent[0].scrollLeft = 0
							}
						}
					} else {
						if (q > 0 && g > B.cells.length - q - 1 && this._togglegroupstate) {
							this._togglegroupstate(n.bounddata, true)
						} else {
							if (g == B.cells.length - 1 - q && this.rowdetails && this.showrowdetailscolumn) {
								this._togglerowdetails(n.bounddata, true);
								this.gridcontent[0].scrollTop = 0;
								this.gridcontent[0].scrollLeft = 0
							}
						}
					}
				} else {
					if (n.boundindex != -1) {
						var K = this.selectedrowindexes.slice(0);
						var l = false;
						if (z.selectionmode != "none" && this._selectrowwithmouse) {
							if (z.selectionmode == "multiplecellsadvanced" || z.selectionmode == "multiplecellsextended" || z.selectionmode == "multiplerowsextended") {
								if (!G.ctrlKey && !G.shiftKey) {
									z.selectedrowindexes = new Array();
									z.selectedcells = new Array()
								}
							}
							if (z.selectionmode.indexOf("cell") == -1) {
								if ((z.selectionmode != "singlerow") || (z.selectedrowindex != n.boundindex && z.selectionmode == "singlerow")) {
									this._applyrowselection(n.boundindex, true, false, null, f.datafield);
									this._selectrowwithmouse(z, d, K, f.datafield, G.ctrlKey, G.shiftKey)
								}
							} else {
								if (f.datafield != null) {
									this._selectrowwithmouse(z, d, K, f.datafield, G.ctrlKey, G.shiftKey);
									this._applycellselection(n.boundindex, f.datafield, true, false)
								}
							}
							if (z._oldselectedcell) {
								if (z._oldselectedcell.datafield == z.selectedcell.datafield && z._oldselectedcell.rowindex == z.selectedcell.rowindex) {
									l = true
								}
							}
							z._oldselectedcell = z.selectedcell
						}
						if (z.autosavestate) {
							if (z.savestate) {
								z.savestate()
							}
						}
						if (z.editable && z.begincelledit) {
							var e = z.editmode == "click" || (l && z.editmode == "selectedcell");
							if (z.selectionmode.indexOf("cell") == -1) {
								if (z.editmode != "dblclick") {
									e = true
								}
							}
							if (e) {
								if (n.boundindex != undefined && f.editable) {
									var t = z.begincelledit(n.boundindex, f.datafield, f.defaulteditorvalue)
								}
							}
							if (z.selectionmode.indexOf("cell") != -1) {
								if (z.editmode == "selectedcell" && !l && z.editcell) {
									z.endcelledit(z.editcell.row, z.editcell.column, false, true)
								}
							}
							return true
						}
					}
				}
			}
			return true
		},
		_columnPropertyChanged : function(e, d, g, f) {
		},
		_rowPropertyChanged : function(g, d, f, e) {
		},
		_serializeObject : function(d) {
			if (d == null) {
				return ""
			}
			var e = "";
			b.each(d, function(g) {
				var h = this;
				if (g > 0) {
					e += ", "
				}
				e += "[";
				var f = 0;
				for (obj in h) {
					if (f > 0) {
						e += ", "
					}
					e += "{" + obj + ":" + h[obj] + "}";
					f++
				}
				e += "]"
			});
			return e
		},
		propertyChangedHandler : function(d, e, h, g) {
			if (this.isInitialized == undefined || this.isInitialized == false) {
				return
			}
			switch (e) {
			case "columnsheight":
				if (d.columnsheight != 25) {
					d._measureElement("column")
				}
				d._render(true, true, true, false, false);
				break;
			case "rowsheight":
				if (g != h) {
					if (d.rowsheight != 25) {
						d._measureElement("cell")
					}
					d.virtualsizeinfo = null;
					d.rendergridcontent(true, false);
					d.refresh()
				}
				break;
			case "scrollMode":
				d.vScrollInstance.thumbStep = d.rowsheight;
				break;
			case "showdefaultloadelement":
				d._builddataloadelement();
				break;
			case "showfiltermenuitems":
			case "showsortmenuitems":
			case "showgroupmenuitems":
				d._initmenu();
				break;
			case "touchmode":
				if (h != g) {
					d._removeHandlers();
					d.touchDevice = null;
					d.vScrollBar.jqxScrollBar({
						touchMode : g
					});
					d.hScrollBar.jqxScrollBar({
						touchMode : g
					});
					d._updateTouchScrolling();
					d._addHandlers()
				}
				break;
			case "autoshowcolumnsmenubutton":
				if (h != g) {
					d._rendercolumnheaders()
				}
				break;
			case "rendergridrows":
				if (h != g) {
					d.updatebounddata()
				}
				break;
			case "editmode":
				if (h != g) {
					d._removeHandlers();
					d._addHandlers()
				}
				break;
			case "source":
				d.virtualsizeinfo = null;
				if (d.showfilterrow && d.filterable && d.filterrow) {
					d.filterrow.remove();
					d._filterrowcache = new Array();
					d.filterrow = null
				}
				d.updatebounddata();
				if (d.virtualmode && !d._loading) {
					d.loadondemand = true;
					d._renderrows(d.virtualsizeinfo)
				}
				break;
			case "horizontalscrollbarstep":
			case "verticalscrollbarstep":
			case "horizontalscrollbarlargestep":
			case "verticalscrollbarlargestep":
				this.vScrollBar.jqxScrollBar({
					step : this.verticalscrollbarstep,
					largestep : this.verticalscrollbarlargestep
				});
				this.hScrollBar.jqxScrollBar({
					step : this.horizontalscrollbarstep,
					largestep : this.horizontalscrollbarlargestep
				});
				break;
			case "closeablegroups":
				if (d._initgroupsheader) {
					d._initgroupsheader()
				}
				break;
			case "showgroupsheader":
				if (h != g) {
					d.rendergridcontent()
				}
				break;
			case "theme":
				if (g != h) {
					if (d.pager) {
						d.pager.removeClass();
						d.pager.addClass(d.toTP("jqx-grid-pager"));
						d.pager.addClass(d.toTP("jqx-widget-header"));
						if (d.pageable && d._updatepagertheme) {
							d._updatepagertheme()
						}
					}
					if (d.groupsheader) {
						d.groupsheader.removeClass();
						d.groupsheader.addClass(d.toTP("jqx-grid-groups-header"));
						d.groupsheader.addClass(d.toTP("jqx-widget-header"))
					}
					d.toolbar.removeClass();
					d.toolbar.addClass(d.toTP("jqx-grid-toolbar"));
					d.toolbar.addClass(d.toTP("jqx-widget-header"));
					d.statusbar.removeClass();
					d.statusbar.addClass(d.toTP("jqx-grid-statusbar"));
					d.statusbar.addClass(d.toTP("jqx-widget-content"));
					d.vScrollBar.jqxScrollBar({
						theme : d.theme
					});
					d.hScrollBar.jqxScrollBar({
						theme : d.theme
					});
					d.host.removeClass();
					d.host.addClass(d.toTP("jqx-grid"));
					d.host.addClass(d.toTP("jqx-reset"));
					d.host.addClass(d.toTP("jqx-rc-all"));
					d.host.addClass(d.toTP("jqx-widget"));
					d.host.addClass(d.toTP("jqx-widget-content"));
					d.bottomRight.removeClass();
					d.bottomRight.addClass(d.toTP("jqx-grid-bottomright"));
					d.toolbar.addClass(d.toTP("jqx-grid-toolbar"));
					d.toolbar.addClass(d.toTP("jqx-widget-header"));
					d.statusbar.addClass(d.toTP("jqx-grid-statusbar"));
					d.statusbar.addClass(d.toTP("jqx-widget-header"));
					d.render()
				}
				break;
			case "showtoolbar":
			case "toolbarheight":
				if (h != g) {
					d._arrange();
					d.refresh()
				}
				break;
			case "showstatusbar":
				if (h != g) {
					if (d.statusbar) {
						if (g) {
							d.statusbar.show()
						} else {
							d.statusbar.hide()
						}
					}
					d._arrange();
					d.refresh()
				}
				break;
			case "statusbarheight":
				if (h != g) {
					d._arrange();
					d.refresh()
				}
				break;
			case "filterable":
				if (h != g) {
					d.render()
				}
				break;
			case "autoshowfiltericon":
			case "showfiltercolumnbackground":
			case "showpinnedcolumnbackground":
			case "showsortcolumnbackground":
				if (h != g) {
					d.rendergridcontent()
				}
				break;
			case "showrowdetailscolumn":
				if (h != g) {
					d.render()
				}
				break;
			case "scrollbarsize":
				if (h != g) {
					d._arrange()
				}
				break;
			case "width":
				if (h != g) {
					if (!this._loading) {
						if (g != h) {
							d._arrange();
							d._updatecolumnwidths();
							d._updatecellwidths();
							d._renderrows(d.virtualsizeinfo)
						}
					}
				}
				break;
			case "height":
				if (h != g) {
					if (!this._loading) {
						if (g != h) {
							var i = d.groupable && d.groups.length > 0;
							var f = d.vScrollBar.css("visibility") != "visible";
							if (!i) {
								d._arrange();
								d.virtualsizeinfo = d._calculatevirtualheight();
								if (parseInt(g) >= parseInt(h)) {
									d.prerenderrequired = true
								}
								if (g != null && g.toString().indexOf("%") != -1) {
									d.prerenderrequired = true
								}
								d._renderrows(d.virtualsizeinfo)
							} else {
								if (g >= h) {
									d._render(true, false, false)
								} else {
									d.rendergridcontent(true, false)
								}
							}
							if (f && d.vScrollBar.css("visibility") == "visible") {
								d._arrange();
								d._updatecolumnwidths();
								d._updatecellwidths()
							}
						}
					}
				}
				break;
			case "altrows":
			case "altstart":
			case "altstep":
				if (h != g) {
					d._renderrows(d.virtualsizeinfo)
				}
				break;
			case "groupsheaderheight":
				if (h != g) {
					d._arrange();
					if (d._initgroupsheader) {
						d._initgroupsheader()
					}
				}
				break;
			case "pagerheight":
				if (h != g) {
					d._initpager()
				}
				break;
			case "selectedrowindex":
				d.selectrow(g);
				break;
			case "selectionmode":
				if (h != g) {
					if (g == "none") {
						d.selectedrowindexes = new Array();
						d.selectedcells = new Array();
						d.selectedrowindex = -1
					}
					d._renderrows(d.virtualsizeinfo)
				}
				break;
			case "showheader":
				if (g) {
					d.columnsheader.css("display", "block")
				} else {
					d.columnsheader.css("display", "none")
				}
				break;
			case "virtualmode":
				if (h != g) {
					d.dataview.virtualmode = d.virtualmode;
					d.dataview.refresh(false);
					d._render(false, false, false)
				}
				break;
			case "columnsmenu":
				if (h != g) {
					d.render()
				}
				break;
			case "columns":
				if (d._serializeObject(d._cachedcolumns) !== d._serializeObject(g)) {
					d._columns = null;
					d._filterrowcache = [];
					d.render()
				} else {
					d._initializeColumns()
				}
				break;
			case "autoheight":
				if (h != g) {
					d._render(false, false, true)
				}
				break;
			case "pagesizeoptions":
			case "pageable":
			case "pagesize":
				if (h != g) {
					if (d._loading) {
						alert(d.loadingerrormessage);
						return
					}
					if (d._initpager) {
						d.dataview.pageable = d.pageable;
						d.dataview.pagenum = 0;
						d.dataview.pagesize = d._getpagesize();
						if (d.virtualmode) {
							d.updatebounddata()
						}
						d.dataview.refresh(true);
						d._initpager();
						if (e == "pagesizeoptions") {
							if (g != null && g.length > 0) {
								d.pagesize = g[0];
								d.dataview.pagesize = g[0];
								d.prerenderrequired = true;
								d._requiresupdate = true;
								d.dataview.pagenum = -1;
								d.gotopage(0)
							}
						}
					}
					d._render(false, false, false)
				}
				break;
			case "groups":
				if (d._serializeObject(h) !== d._serializeObject(g)) {
					d.dataview.groups = g;
					d._refreshdataview();
					d._render(true, true, true, false)
				}
				break;
			case "groupable":
				if (h != g) {
					d.dataview.groupable = d.groupable;
					d.dataview.pagenum = 0;
					d.dataview.refresh(false);
					d._render(false, false, true)
				}
				break;
			case "disabled":
				if (g) {
					d.host.addClass(d.toThemeProperty("jqx-fill-state-disabled"))
				} else {
					d.host.removeClass(d.toThemeProperty("jqx-fill-state-disabled"))
				}
				break
			}
		}
	});
	function c(d, e) {
		this.owner = d;
		this.datafield = null;
		this.displayfield = null;
		this.text = "";
		this.sortable = true;
		this.hideable = true;
		this.editable = true;
		this.hidden = false;
		this.groupable = true;
		this.renderer = null;
		this.cellsrenderer = null;
		this.checkchange = null, this.threestatecheckbox = false;
		this.buttonclick = null, this.columntype = null;
		this.cellsformat = "";
		this.align = "left";
		this.cellsalign = "left";
		this.width = "auto";
		this.minwidth = 25;
		this.maxwidth = "auto";
		this.pinned = false;
		this.visibleindex = -1;
		this.filterable = true;
		this.filter = null;
		this.filteritems = [];
		this.resizable = true;
		this.initeditor = null;
		this.createeditor = null;
		this.validation = null;
		this.classname = "";
		this.cellclassname = "";
		this.cellendedit = null;
		this.cellbeginedit = null;
		this.cellvaluechanging = null;
		this.aggregates = null;
		this.aggregatesrenderer = null;
		this.menu = true;
		this.createfilterwidget = null;
		this.filtertype = "default";
		this.filtercondition = null;
		this.rendered = null;
		this.exportable = true;
		this.draggable = true;
		this.getcolumnproperties = function() {
			return {
				sortable : this.sortable,
				hideable : this.hideable,
				hidden : this.hidden,
				groupable : this.groupable,
				width : this.width,
				align : this.align,
				editable : this.editable,
				minwidth : this.minwidth,
				maxwidth : this.maxwidth,
				resizable : this.resizable,
				datafield : this.datafield,
				text : this.text,
				exportable : this.exportable,
				cellsalign : this.cellsalign,
				pinned : this.pinned,
				cellsformat : this.cellsformat,
				columntype : this.columntype,
				classname : this.classname,
				cellclassname : this.cellclassname,
				menu : this.menu
			}
		}, this.setproperty = function(f, g) {
			if (this[f]) {
				var h = this[f];
				this[f] = g;
				this.owner._columnPropertyChanged(this, f, g, h)
			}
		};
		this._initfields = function(f) {
			if (f != null) {
				if (f.datafield != undefined) {
					this.datafield = f.datafield
				}
				if (f.dataField != undefined) {
					this.datafield = f.dataField
				}
				if (f.displayfield != undefined) {
					this.displayfield = f.displayfield
				} else {
					this.displayfield = this.datafield
				}
				if (f.text != undefined) {
					this.text = f.text
				}
				if (f.sortable != undefined) {
					this.sortable = f.sortable
				}
				if (f.hideable != undefined) {
					this.hideable = f.hideable
				}
				if (f.hidden != undefined) {
					this.hidden = f.hidden
				}
				if (f.groupable != undefined) {
					this.groupable = f.groupable
				}
				if (f.renderer != undefined) {
					this.renderer = f.renderer
				}
				if (f.align != undefined) {
					this.align = f.align
				}
				if (f.cellsalign != undefined) {
					this.cellsalign = f.cellsalign
				}
				if (f.cellsformat != undefined) {
					this.cellsformat = f.cellsformat
				}
				if (f.width != undefined) {
					this.width = f.width
				}
				if (f.minwidth != undefined) {
					this.minwidth = f.minwidth
				}
				if (f.maxwidth != undefined) {
					this.maxwidth = f.maxwidth
				}
				if (f.cellsrenderer != undefined) {
					this.cellsrenderer = f.cellsrenderer
				}
				if (f.columntype != undefined) {
					this.columntype = f.columntype
				}
				if (f.checkchange != undefined) {
					this.checkchange = f.checkchange
				}
				if (f.buttonclick != undefined) {
					this.buttonclick = f.buttonclick
				}
				if (f.pinned != undefined) {
					this.pinned = f.pinned
				}
				if (f.visibleindex != undefined) {
					this.visibleindex = f.visibleindex
				}
				if (f.filterable != undefined) {
					this.filterable = f.filterable
				}
				if (f.filter != undefined) {
					this.filter = f.filter
				}
				if (f.resizable != undefined) {
					this.resizable = f.resizable
				}
				if (f.editable != undefined) {
					this.editable = f.editable
				}
				if (f.initeditor != undefined) {
					this.initeditor = f.initeditor
				}
				if (f.createeditor != undefined) {
					this.createeditor = f.createeditor
				}
				if (f.validation != undefined) {
					this.validation = f.validation
				}
				if (f.cellbeginedit != undefined) {
					this.cellbeginedit = f.cellbeginedit
				}
				if (f.cellendedit != undefined) {
					this.cellendedit = f.cellendedit
				}
				if (f.classname != undefined) {
					this.classname = f.classname
				}
				if (f.cellclassname != undefined) {
					this.cellclassname = f.cellclassname
				}
				if (f.menu != undefined) {
					this.menu = f.menu
				}
				if (f.aggregates != undefined) {
					this.aggregates = f.aggregates
				}
				if (f.aggregatesrenderer != undefined) {
					this.aggregatesrenderer = f.aggregatesrenderer
				}
				if (f.createfilterwidget != undefined) {
					this.createfilterwidget = f.createfilterwidget
				}
				if (f.filtertype != undefined) {
					this.filtertype = f.filtertype
				}
				if (f.rendered != undefined) {
					this.rendered = f.rendered
				}
				if (f.exportable != undefined) {
					this.exportable = f.exportable
				}
				if (f.filteritems != undefined) {
					this.filteritems = f.filteritems
				}
				if (f.cellvaluechanging != undefined) {
					this.cellvaluechanging = f.cellvaluechanging
				}
				if (f.draggable != undefined) {
					this.draggable = f.draggable
				}
				if (f.filtercondition != undefined) {
					this.filtercondition = f.filtercondition
				}
				if (f.threestatecheckbox != undefined) {
					this.threestatecheckbox = f.threestatecheckbox
				}
			}
		};
		this._initfields(e);
		return this
	}
	function a(d, e) {
		this.setdata = function(f) {
			if (f != null) {
				this.bounddata = f;
				this.boundindex = f.boundindex;
				this.visibleindex = f.visibleindex;
				this.group = f.group;
				this.parentbounddata = f.parentItem;
				this.uniqueid = f.uniqueid;
				this.level = f.level
			}
		};
		this.setdata(e);
		this.parentrow = null;
		this.subrows = new Array();
		this.owner = d;
		this.height = 25;
		this.hidden = false;
		this.rowdetails = null;
		this.rowdetailsheight = 100;
		this.rowdetailshidden = true;
		this.top = -1;
		this.setrowinfo = function(f) {
			this.hidden = f.hidden;
			this.rowdetails = f.rowdetails;
			this.rowdetailsheight = f.rowdetailsheight;
			this.rowdetailshidden = !f.showdetails;
			this.height = f.height
		};
		return this
	}
	b.jqx.collection = function(d) {
		this.records = new Array();
		this.owner = d;
		this.updating = false;
		this.beginupdate = function() {
			this.updating = true
		};
		this.resumeupdate = function() {
			this.updating = false
		};
		this._raiseEvent = function(e) {
		};
		this.clear = function() {
			this.records = new Array()
		};
		this.replace = function(f, e) {
			this.records[f] = e;
			if (!this.updating) {
				this._raiseEvent({
					type : "replace",
					element : e
				})
			}
		};
		this.isempty = function(e) {
			if (this.records[e] == undefined) {
				return true
			}
			return false
		};
		this.initialize = function(e) {
			if (e < 1) {
				e = 1
			}
			this.records[e - 1] = -1
		};
		this.length = function() {
			return this.records.length
		};
		this.indexOf = function(e) {
			return this.records.indexOf(e)
		};
		this.add = function(e) {
			if (e == null) {
				return false
			}
			this.records[this.records.length] = e;
			if (!this.updating) {
				this._raiseEvent({
					type : "add",
					element : e
				})
			}
			return true
		};
		this.insertAt = function(f, e) {
			if (f == null || f == undefined) {
				return false
			}
			if (e == null) {
				return false
			}
			if (f >= 0) {
				if (f < this.records.length) {
					this.records.splice(f, 0, e);
					if (!this.updating) {
						this._raiseEvent({
							type : "insert",
							index : f,
							element : e
						})
					}
					return true
				} else {
					return this.add(e)
				}
			}
			return false
		};
		this.remove = function(f) {
			if (f == null || f == undefined) {
				return false
			}
			var e = this.records.indexOf(f);
			if (e != -1) {
				this.records.splice(e, 1);
				if (!this.updating) {
					this._raiseEvent({
						type : "remove",
						element : f
					})
				}
				return true
			}
			return false
		};
		this.removeAt = function(f) {
			if (f == null || f == undefined) {
				return false
			}
			if (f < 0) {
				return false
			}
			if (f < this.records.length) {
				var e = this.records[f];
				this.records.splice(f, 1);
				if (!this.updating) {
					this._raiseEvent({
						type : "removeAt",
						index : f,
						element : e
					})
				}
				return true
			}
			return false
		};
		return this
	};
	b.jqx.dataview = function() {
		this.self = this;
		this.grid = null;
		this.uniqueId = "id";
		this.records = [];
		this.rows = [];
		this.columns = [];
		this.groups = [];
		this.filters = new Array();
		this.updated = null;
		this.update = null;
		this.suspend = false;
		this.pagesize = 0;
		this.pagenum = 0;
		this.totalrows = 0;
		this.totalrecords = 0;
		this.groupable = true;
		this.loadedrecords = [];
		this.loadedrootgroups = [];
		this.loadedgroups = [];
		this.loadedgroupsByKey = [];
		this.virtualmode = true;
		this._cachegrouppages = new Array();
		this.source = null;
		this.changedrecords = new Array();
		this.rowschangecallback = null;
		this.suspendupdate = function() {
			this.suspend = true
		}, this.isupdating = function() {
			return this.suspend
		}, this.resumeupdate = function(d) {
			this.suspend = false;
			if (d == undefined) {
				d = true
			}
			this.refresh(d)
		}, this.getrecords = function() {
			return this.records
		}, this.clearrecords = function() {
			this.recordids = new Array()
		};
		this.databind = function(d, n) {
			var o = d._source ? true : false;
			var e = null;
			if (o) {
				e = d;
				d = d._source
			} else {
				e = new b.jqx.dataAdapter(d, {
					autoBind : false
				})
			}
			var g = function(m) {
				e.recordids = [];
				e.records = new Array();
				e.cachedrecords = new Array();
				e.originaldata = new Array();
				e._options.virtualmode = m.virtualmode;
				e._options.totalrecords = m.totalrecords;
				e._options.originaldata = m.originaldata;
				e._options.recordids = m.recordids;
				e._options.cachedrecords = new Array();
				e._options.pagenum = m.pagenum;
				e._options.pageable = m.pageable;
				if (d.type != undefined) {
					e._options.type = d.type
				}
				if (d.formatdata != undefined) {
					e._options.formatData = d.formatdata
				}
				if (d.contenttype != undefined) {
					e._options.contentType = d.contenttype
				}
				if (d.async != undefined) {
					e._options.async = d.async
				}
				if (d.updaterow != undefined) {
					e._options.updaterow = d.updaterow
				}
				if (d.addrow != undefined) {
					e._options.addrow = d.addrow
				}
				if (d.deleterow != undefined) {
					e._options.deleterow = d.deleterow
				}
				if (m.pagesize == 0) {
					m.pagesize = 10
				}
				e._options.pagesize = m.pagesize
			};
			var q = function(v) {
				v.totalrecords = e.totalrecords;
				if (!v.virtualmode) {
					v.originaldata = e.originaldata;
					v.records = e.records;
					v.recordids = e.recordids;
					v.cachedrecords = e.cachedrecords
				} else {
					var m = {
						startindex : v.pagenum * v.pagesize,
						endindex : (v.pagenum * v.pagesize + v.pagesize)
					};
					if (d.recordstartindex) {
						m.startindex = d.recordstartindex
					}
					if (d.recordendindex) {
						m.endindex = d.recordendindex
					} else {
						if (!v.grid.pageable) {
							m.endindex = m.startindex + 100;
							if (v.grid.autoheight) {
								m.endindex = m.startindex + v.totalrecords
							}
						}
					}
					m.data = e.records;
					if (v.grid.rendergridrows && v.totalrecords > 0) {
						d.records = v.grid.rendergridrows(m)
					}
					if (!d.records || v.totalrecords == 0) {
						d.records = new Array()
					}
					v.originaldata = d.records;
					v.records = d.records;
					v.cachedrecords = d.records
				}
			};
			g(this);
			this.source = d;
			if (n !== undefined) {
				uniqueId = n
			}
			var r = this;
			switch (d.datatype) {
			case "local":
			case "array":
			default:
				if (d.localdata == null) {
					d.localdata = []
				}
				if (d.localdata != null) {
					e.unbindBindingUpdate(r.grid.element.id);
					e.dataBind();
					var p = function(v) {
						if (v != undefined) {
							var w = e._changedrecords[0];
							if (w) {
								b.each(e._changedrecords, function() {
									var x = this.index;
									var y = this.record;
									r.grid._updateFromAdapter = true;
									switch (v) {
									case "update":
										var z = r.grid.getrowid(x);
										r.grid.updaterow(z, y);
										r.grid._updateFromAdapter = false;
										return;
									case "add":
										r.grid.addrow(null, y);
										r.grid._updateFromAdapter = false;
										return;
									case "remove":
										var z = r.grid.getrowid(x);
										r.grid.deleterow(z);
										r.grid._updateFromAdapter = false;
										return
									}
								})
							}
						}
						var m = r.totalrecords;
						q(r, v);
						if (v == "updateData") {
							r.refresh();
							r.grid._updateGridData()
						} else {
							if (d.recordstartindex && this.virtualmode) {
								r.updateview(d.recordstartindex, d.recordstartindex + r.pagesize)
							} else {
								r.refresh()
							}
							r.update(m != r.totalrecords)
						}
					};
					p();
					e.bindBindingUpdate(r.grid.element.id, p)
				}
				break;
			case "json":
			case "jsonp":
			case "xml":
			case "xhtml":
			case "script":
			case "text":
			case "csv":
			case "tab":
				if (d.localdata != null) {
					e.unbindBindingUpdate(r.grid.element.id);
					e.dataBind();
					var p = function(v) {
						var m = r.totalrecords;
						q(r);
						if (v == "updateData") {
							r.refresh();
							r.grid._updateGridData()
						} else {
							if (d.recordstartindex) {
								r.updateview(d.recordstartindex, d.recordstartindex + r.pagesize)
							} else {
								r.refresh()
							}
							r.update(m != r.totalrecords)
						}
					};
					p();
					e.bindBindingUpdate(r.grid.element.id, p);
					return
				}
				var l = {};
				var i = 0;
				var t = {};
				for ( var s = 0; s < this.filters.length; s++) {
					var j = this.filters[s].datafield;
					var f = this.filters[s].filter;
					var h = f.getfilters();
					t[j + "operator"] = f.operator;
					for ( var k = 0; k < h.length; k++) {
						h[k].datafield = j;
						var u = h[k].value;
						t["filtervalue" + i] = u.toString();
						t["filtercondition" + i] = h[k].condition;
						t["filteroperator" + i] = h[k].operator;
						t["filterdatafield" + i] = j;
						i++
					}
				}
				t.filterscount = i;
				t.groupscount = r.groups.length;
				for ( var s = 0; s < r.groups.length; s++) {
					t["group" + s] = r.groups[s]
				}
				if (d.recordstartindex == undefined) {
					d.recordstartindex = 0
				}
				if (d.recordendindex == undefined || d.recordendindex == 0) {
					if (r.grid.height && r.grid.height.toString().indexOf("%") == -1) {
						d.recordendindex = parseInt(r.grid.height) / r.grid.rowsheight;
						d.recordendindex += 2
					} else {
						d.recordendindex = b(window).height() / r.grid.rowsheight
					}
				}
				b.extend(t, {
					sortdatafield : r.sortfield,
					sortorder : r.sortfielddirection,
					pagenum : r.pagenum,
					pagesize : r.grid.pagesize,
					recordstartindex : d.recordstartindex,
					recordendindex : d.recordendindex
				});
				if (e._options.data) {
					b.extend(e._options.data, t)
				} else {
					if (d.data) {
						b.extend(t, d.data)
					}
					e._options.data = t
				}
				var p = function() {
					var m = r.totalrecords;
					q(r);
					if (d.recordstartindex) {
						r.updateview(d.recordstartindex, d.recordstartindex + r.pagesize)
					} else {
						r.refresh()
					}
					r.update(m != r.totalrecords)
				};
				e.unbindDownloadComplete(r.grid.element.id);
				e.bindDownloadComplete(r.grid.element.id, p);
				e.dataBind()
			}
		};
		this.getid = function(g, e, f) {
			if (b(g, e).length > 0) {
				return b(g, e).text()
			}
			if (g) {
				if (g.toString().length > 0) {
					var d = b(e).attr(g);
					if (d != null && d.toString().length > 0) {
						return d
					}
				}
			}
			return f
		};
		this.getvaluebytype = function(g, d) {
			var e = g;
			if (d.type == "date") {
				var f = new Date(g);
				if (f.toString() == "NaN" || f.toString() == "Invalid Date") {
					if (b.jqx.dataFormat) {
						g = b.jqx.dataFormat.tryparsedate(g)
					} else {
						g = f
					}
				} else {
					g = f
				}
				if (g == null) {
					g = e
				}
			} else {
				if (d.type == "float") {
					var g = parseFloat(g);
					if (isNaN(g)) {
						g = e
					}
				} else {
					if (d.type == "int") {
						var g = parseInt(g);
						if (isNaN(g)) {
							g = e
						}
					} else {
						if (d.type == "bool") {
							if (g != null) {
								if (g.toLowerCase() == "false") {
									g = false
								} else {
									if (g.toLowerCase() == "true") {
										g = true
									}
								}
							}
							if (g == 1) {
								g = true
							} else {
								if (g == 0) {
									g = false
								} else {
									g = ""
								}
							}
						}
					}
				}
			}
			return g
		};
		this.setpaging = function(d) {
			if (d.pageSize != undefined) {
				this.pagesize = d.pageSize
			}
			if (d.pageNum != undefined) {
				this.pagenum = Math.min(d.pageNum, Math.ceil(this.totalrows / this.pagesize))
			}
			this.refresh()
		};
		this.getpagingdetails = function() {
			return {
				pageSize : this.pagesize,
				pageNum : this.pagenum,
				totalrows : this.totalrows
			}
		};
		this._clearcaches = function() {
			this.sortcache = {};
			this.sortdata = null;
			this.changedrecords = new Array();
			this.records = new Array();
			this.rows = new Array();
			this.cacheddata = new Array();
			this.originaldata = new Array();
			this.bounditems = new Array();
			this.loadedrecords = new Array();
			this.loadedrootgroups = new Array();
			this.loadedgroups = new Array();
			this.loadedgroupsByKey = new Array();
			this._cachegrouppages = new Array();
			this.recordsbyid = new Array();
			this.cachedrecords = new Array();
			this.recordids = new Array()
		};
		this.addfilter = function(g, f) {
			var e = -1;
			for ( var d = 0; d < this.filters.length; d++) {
				if (this.filters[d].datafield == g) {
					e = d;
					break
				}
			}
			if (e == -1) {
				this.filters[this.filters.length] = {
					filter : f,
					datafield : g
				}
			} else {
				this.filters[e] = {
					filter : f,
					datafield : g
				}
			}
		};
		this.removefilter = function(e) {
			for ( var d = 0; d < this.filters.length; d++) {
				if (this.filters[d].datafield == e) {
					this.filters.splice(d, 1);
					break
				}
			}
		};
		this.getItemFromIndex = function(d) {
			return this.records[d]
		};
		this.updaterow = function(j, l, h) {
			var d = this.filters && this.filters.length > 0;
			if (!d && l != undefined && j != undefined) {
				l.uid = j;
				if (!(l[this.source.id])) {
					l[this.source.id] = l.uid
				}
				var e = this.recordsbyid["id" + j];
				var k = this.records.indexOf(e);
				if (k == -1) {
					return false
				}
				this.records[k] = l;
				if (this.cachedrecords) {
					this.cachedrecords[k] = l
				}
				if (h == true || h == undefined) {
					this.refresh()
				}
				this.changedrecords[l.uid] = {
					Type : "Update",
					OldData : e,
					Data : l
				};
				return true
			} else {
				if (this.filters && this.filters.length > 0) {
					var f = this.cachedrecords;
					var e = null;
					var k = -1;
					for ( var g = 0; g < f.length; g++) {
						if (f[g].uid == j) {
							e = f[g];
							k = g;
							break
						}
					}
					if (e) {
						this.cachedrecords[k] = l;
						if (h == true || h == undefined) {
							this.refresh()
						}
						return true
					}
				}
			}
			return false
		};
		this.addrow = function(h, i, d, g) {
			if (i != undefined) {
				if (!h) {
					i.uid = this.getid(this.source.id, i, this.totalrecords);
					var e = this.recordsbyid["id" + i.uid];
					while (e != null) {
						var f = Math.floor(Math.random() * 10000).toString();
						i.uid = f;
						e = this.recordsbyid["id" + f]
					}
				} else {
					i.uid = h
				}
				if (!(i[this.source.id])) {
					if (this.source.id != undefined) {
						i[this.source.id] = i.uid
					}
				}
				if (d == "last") {
					this.records.push(i)
				} else {
					this.records.splice(0, 0, i)
				}
				if (this.filters && this.filters.length > 0) {
					if (d == "last") {
						this.cachedrecords.push(i)
					} else {
						this.cachedrecords.splice(0, 0, i)
					}
				}
				this.totalrecords++;
				if (g == true || g == undefined) {
					this.refresh()
				}
				this.changedrecords[i.uid] = {
					Type : "New",
					Data : i
				};
				return true
			}
			return false
		};
		this.deleterow = function(j, h) {
			if (j != undefined) {
				var d = this.filters && this.filters.length > 0;
				if (this.recordsbyid["id" + j] && !d) {
					var e = this.recordsbyid["id" + j];
					var k = this.records.indexOf(e);
					this.changedrecords[j] = {
						Type : "Delete",
						Data : this.records[k]
					};
					this.records.splice(k, 1);
					this.totalrecords--;
					if (h == true || h == undefined) {
						this.refresh()
					}
					return true
				} else {
					if (this.filters && this.filters.length > 0) {
						var f = this.cachedrecords;
						var e = null;
						var k = -1;
						for ( var g = 0; g < f.length; g++) {
							if (f[g].uid == j) {
								e = f[g];
								k = g;
								break
							}
						}
						if (e) {
							this.cachedrecords.splice(k, 1);
							if (h == true || h == undefined) {
								this.totalrecords = 0;
								this.records = this.cachedrecords;
								this.refresh()
							}
							return true
						}
					}
				}
				return false
			}
			return false
		};
		this.reload = function(f, d, r, g, h, u, t) {
			var m = this;
			var l = new Array();
			var o = f;
			var i = d;
			var j = r;
			var p = g;
			var k = i.length;
			var w = 0;
			var e = 0;
			var s, n;
			this.columns = [];
			this.bounditems = new Array();
			this.loadedrecords = new Array();
			this.loadedrootgroups = new Array();
			this.loadedgroups = new Array();
			this.loadedgroupsByKey = new Array();
			this._cachegrouppages = new Array();
			this.recordsbyid = {};
			if (this.totalrecords == 0) {
				Object.size = function(z) {
					var y = 0, x;
					for (x in z) {
						if (z.hasOwnProperty(x)) {
							y++
						}
					}
					return y
				};
				var v = Object.size(o);
				this.totalrecords = v;
				b.each(this.records, function(y) {
					var z = this;
					var x = 0;
					b.each(z, function(A, B) {
						m.columns[x++] = A
					});
					return false
				})
			}
			if (this.virtualmode) {
				if (this.pageable) {
					this.updateview();
					return
				}
				var u = 0;
				if (!this.groupable) {
					this.updateview();
					return
				} else {
					var t = this.totalrecords
				}
			} else {
				var u = 0;
				var t = this.totalrecords
			}
			if (this.groupable && this.groups.length > 0 && this.loadgrouprecords) {
				var q = u;
				q = this.loadgrouprecords(0, u, t, j, e, p, i, k, l)
			} else {
				w = this.loadflatrecords(u, t, j, e, p, i, k, l)
			}
			if (k > e) {
				i.splice(e, k - e)
			}
			if (this.groups.length > 0 && this.groupable) {
				this.totalrows = q
			} else {
				this.totalrows = w
			}
			return l
		};
		this.loadflatrecords = function(d, o, e, p, l, u, n, q) {
			var t = this;
			var k = d;
			var m = d;
			o = Math.min(o, this.totalrecords);
			var g = this.sortdata != null;
			var f = this.source.id && (this.source.datatype == "local" || this.source.datatype == "array" || this.source.datatype == "");
			var j = g ? this.sortdata : this.records;
			for ( var h = d; h < o; h++) {
				var s = {};
				if (!g) {
					s = b.extend({}, j[h]);
					id = s[t.uniqueId];
					s.boundindex = k;
					t.loadedrecords[k] = s;
					if (s.uid == undefined) {
						s.uid = t.getid(t.source.id, s, k)
					}
					t.recordsbyid["id" + s.uid] = j[h];
					s.uniqueid = t.generatekey();
					t.bounditems[this.bounditems.length] = s
				} else {
					s = b.extend({}, j[h].value);
					id = s[t.uniqueId];
					s.boundindex = j[h].index;
					if (s.uid == undefined) {
						s.uid = t.getid(t.source.id, s, s.boundindex)
					}
					t.recordsbyid["id" + s.uid] = j[h].value;
					t.loadedrecords[k] = s;
					s.uniqueid = t.generatekey();
					t.bounditems[s.boundindex] = s
				}
				if (p >= n || id != u[p][t.uniqueId] || (l && l[id])) {
					q[q.length] = p
				}
				u[p] = s;
				p++;
				s.visibleindex = m;
				m++;
				k++
			}
			if (t.grid.summaryrows) {
				var r = k;
				b.each(t.grid.summaryrows, function() {
					var i = b.extend({}, this);
					i.boundindex = o++;
					t.loadedrecords[r] = i;
					i.uniqueid = t.generatekey();
					t.bounditems[t.bounditems.length] = i;
					u[p] = i;
					p++;
					i.visibleindex = m;
					m++;
					r++
				})
			}
			return m
		}, this.updateview = function(n, o) {
			var q = this;
			var k = this.pagesize * this.pagenum;
			var m = 0;
			var r = new Array();
			var e = this.filters;
			var j = this.updated;
			var l = r.length;
			if (this.pageable) {
				if (this.virtualmode) {
					if (!this.groupable || this.groups.length == 0) {
						this.loadflatrecords(this.pagesize * this.pagenum, this.pagesize * (1 + this.pagenum), e, m, j, r, l, []);
						this.totalrows = r.length
					} else {
						if (this.groupable && this.groups.length > 0 && this.loadgrouprecords) {
							if (this._cachegrouppages[this.pagenum + "_" + this.pagesize] != undefined) {
								this.rows = this._cachegrouppages[this.pagenum + "_" + this.pagesize];
								this.totalrows = this.rows.length;
								return
							}
							this.loadgrouprecords(0, this.pagesize * this.pagenum, this.pagesize * (1 + this.pagenum), e, m, j, r, l, []);
							this._cachegrouppages[this.pagenum + "_" + this.pagesize] = this.rows;
							this.totalrows = this.rows.length;
							return
						}
					}
				}
			} else {
				if (this.virtualmode && (!this.groupable || this.groups.length == 0)) {
					var g = this.pagesize;
					if (g == 0) {
						g = Math.min(100, this.totalrecords)
					}
					var d = g * this.pagenum;
					if (this.loadedrecords.length == 0) {
						d = 0
					}
					if (n != null && o != null) {
						this.loadflatrecords(n, o, e, m, j, r, l, [])
					} else {
						this.loadflatrecords(this.pagesize * this.pagenum, this.pagesize * (1 + this.pagenum), e, m, j, r, l, [])
					}
					this.totalrows = this.loadedrecords.length;
					this.rows = r;
					if (r.length >= g) {
						return
					}
				}
			}
			if (this.groupable && this.pageable && this.groups.length > 0 && this._updategroupsinpage) {
				r = this._updategroupsinpage(q, e, k, m, l, this.pagesize * this.pagenum, this.pagesize * (1 + this.pagenum))
			} else {
				for ( var h = this.pagesize * this.pagenum; h < this.pagesize * (1 + this.pagenum); h++) {
					var p = h < this.loadedrecords.length ? this.loadedrecords[h] : null;
					if (p == null) {
						continue
					}
					if (!this.pagesize || (k >= this.pagesize * this.pagenum && k <= this.pagesize * (this.pagenum + 1))) {
						r[m] = p;
						m++
					}
					k++
				}
			}
			if ((r.length == 0 || r.length < this.pagesize) && !this.pageable && this.virtualmode) {
				m = r.length;
				var f = r.length;
				for ( var h = this.pagesize * this.pagenum; h < this.pagesize * (1 + this.pagenum) - f; h++) {
					var p = {};
					p.boundindex = h + f;
					p.visibleindex = h + f;
					p.uniqueid = q.generatekey();
					p.empty = true;
					q.bounditems[h + f] = p;
					r[m] = p;
					m++
				}
			}
			this.rows = r
		};
		this.generatekey = function() {
			var d = function() {
				return (((1 + Math.random()) * 65536) | 0).toString(16).substring(1)
			};
			return (d() + d() + "-" + d() + "-" + d() + "-" + d() + "-" + d() + d() + d())
		};
		this.reloaddata = function() {
			this.reload(this.records, this.rows, this.filter, this.updated, true)
		};
		this.refresh = function(h) {
			if (this.suspend) {
				return
			}
			if (h == undefined) {
				h = true
			}
			var l = this.rows.length;
			var k = this.totalrows;
			if (this.filters.length > 0 && !this.virtualmode) {
				var e = "";
				var g = this.cachedrecords.length;
				var s = new Array();
				this.totalrecords = 0;
				var n = this.cachedrecords;
				this._dataIndexToBoundIndex = new Array();
				var f = this.filters.length;
				if (this.source != null && this.source.filter != undefined && this.source.localdata != undefined) {
					s = this.source.filter(this.filters, n, g);
					if (s == undefined) {
						s = new Array()
					}
					this.records = s
				} else {
					if (this.source.filter == null || this.source.filter == undefined) {
						for ( var u = 0; u < g; u++) {
							var o = n[u];
							var d = undefined;
							for ( var m = 0; m < f; m++) {
								var e = this.filters[m].filter;
								var r = o[this.filters[m].datafield];
								var t = e.evaluate(r);
								if (d == undefined) {
									d = t
								} else {
									if (e.operator == "or") {
										d = d || t
									} else {
										d = d && t
									}
								}
							}
							if (d) {
								s[s.length] = b.extend({
									dataindex : u
								}, o);
								this._dataIndexToBoundIndex[u] = {
									boundindex : s.length - 1
								}
							} else {
								this._dataIndexToBoundIndex[u] = null
							}
						}
						this.records = s
					}
				}
				if (this.sortdata) {
					var i = this.sortfield;
					if (this.sortcache[i]) {
						this.sortdata = null;
						var p = this.sortcache[i].direction;
						this.sortcache[i] = null;
						this.sortby(this.sortfield, p);
						return
					}
				}
			} else {
				if (this.filters.length == 0 && !this.virtualmode) {
					if (this.cachedrecords) {
						this.totalrecords = 0;
						var n = this.cachedrecords;
						this.records = n;
						if (this.sortdata) {
							var i = this.sortfield;
							if (this.sortcache[i]) {
								this.sortdata = null;
								var p = this.sortcache[i].direction;
								this.sortcache[i] = null;
								this.sortby(this.sortfield, p);
								return
							}
						}
					}
				}
			}
			var q = this.reload(this.records, this.rows, this.filter, this.updated, h);
			this.updated = null;
			if (this.rowschangecallback != null) {
				if (k != totalrows) {
					this.rowschangecallback({
						type : "PagingChanged",
						data : getpagingdetails()
					})
				}
				if (l != rows.length) {
					this.rowschangecallback({
						type : "RowsCountChanged",
						data : {
							previous : l,
							current : rows.length
						}
					})
				}
				if (q.length > 0 || l != rows.length) {
					this.rowschangecallback({
						type : "RowsChanged",
						data : {
							previous : l,
							current : rows.length,
							diff : q
						}
					})
				}
			}
		};
		return this
	}
})(jQuery);